-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathjquery.detect_timezone.js
More file actions
41 lines (33 loc) · 897 Bytes
/
jquery.detect_timezone.js
File metadata and controls
41 lines (33 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* jQuery Detect Timezone plugin
*
* Copyright (c) 2011 Scott Watermasysk (scottwater@gmail.com)
* Provided under the Do Whatever You Want With This Code License. (same as detect_timezone).
*
*/
(function( $ ){
$.fn.set_timezone = function(options) {
this.val(this.get_timezone(options));
return this;
};
$.fn.get_timezone = function(options) {
var settings = {
'debug' : false,
'default' : 'America/New_York'
};
if(options) {
$.extend( settings, options );
}
var tz_info = jstz.determine_timezone();
var timezone = tz_info.timezone;
if (timezone != 'undefined') {
timezone.ambiguity_check();
return timezone.olson_tz;
} else {
if(settings.debug) {
alert('no timezone to be found. using default.')
}
return settings.default
}
};
})( jQuery );