From 1391f385582f5fe816621ac5c1040ef1eee9e597 Mon Sep 17 00:00:00 2001 From: Jesse Gumm Date: Sun, 24 Mar 2013 14:00:11 -0500 Subject: [PATCH] Add default_timezone environemnt variable --- src/qdate.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/qdate.erl b/src/qdate.erl index cd8ff10..9fe68a2 100644 --- a/src/qdate.erl +++ b/src/qdate.erl @@ -40,7 +40,17 @@ %% It's used to convert to and from unixtime, since unixtime starts %% 1970-01-01 12:00am -define(UNIXTIME_BASE,62167219200). --define(DEFAULT_TZ, "GMT"). + +%% This is the timezone only if the qdate application variable +%% "default_timezone" isn't set or is set to undefined. +%% It's recommended that your app sets the var in a config, or at least using +%% +%% application:set_env(qdate, default_timezone, "GMT"). +%% +-define(DEFAULT_TZ, case application:get_env(qdate, default_timezone) of + undefined -> "GMT"; + TZ -> TZ + end). to_string(Format) -> to_string(Format, now()).