Permalink
Browse files

add a fallback for setting the initial timezone using /etc/timezone

  • Loading branch information...
1 parent 9d6a9f2 commit f403ae146aaff7e93554dab7eb5d3575259c50d6 @TooTallNate committed Aug 18, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 index.js
View
11 index.js
@@ -117,6 +117,17 @@ if (!exports.currentTimezone) {
}
}
+if (!exports.currentTimezone) {
+ debug('"currentTimezone" still not set. Checking "/etc/timezone"');
+ try {
+ var zone = fs.readFileSync('/etc/timezone', 'utf8').trim();
+ exports.currentTimezone = process.env.TZ = zone;
+ debug('resolved initial timezone:', zone);
+ } catch (e) {
+ debug(e);
+ }
+}
+
/**
* The user-facing 'tzset' function is a thin wrapper around the native binding to
* 'tzset()'. This function accepts a timezone String to set the process' timezone

0 comments on commit f403ae1

Please sign in to comment.