/**
* Get/Set any user's timezone for the current session using JSTZ.
*
* @resource {
* @name jsTimezoneDetect
* @author Jon Nylander
* @version 1.0.6
* @see {@link https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.6/jstz.js|JSTZ}
* }
* @author Davey Jacobson
*/
(function( $ ) {
var BIN = {
_jstz: function( callback ) {
if ( typeof jstz === undefined ) {
$.getScript( 'https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.6/jstz.min.js', callback );
}
else {
if ( callback && typeof(callback) === 'function' ) {
callback();
}
}
}
};
var UTIL = {
userTimezone: function( userTZ ) {
BIN.jstz(function() {
var tz = jstz.determine() || 'UTC';
if ( !sessionStorage.timezone ) {
sessionStorage.setItem( 'timezone', tz.name() );
}
userTZ = sessionStorage.timezone;
});
return userTZ;
}
};
$(document).ready(function() {
UTIL.userTimezone();
});
}(jQuery));
Get/Set any user's timezone for the current session using JSTZ.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.