Skip to content

Commit

Permalink
add a fallback for setting the initial timezone using /etc/timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Aug 18, 2012
1 parent 9d6a9f2 commit f403ae1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions index.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 * 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 * 'tzset()'. This function accepts a timezone String to set the process' timezone
Expand Down

0 comments on commit f403ae1

Please sign in to comment.