Added options for primary & local timezones, and show and sort by offset

This commit is contained in:
2015-09-28 13:12:06 +08:00
parent 8481a76b60
commit f7203e287d
5 changed files with 36 additions and 4 deletions
+5 -1
View File
@@ -16,10 +16,12 @@ angular.module('angular-timezone-selector', [])
.factory('timezones', ['_', 'moment', function (_, moment) {
var timezoneMap = {}
_.forEach(moment.tz.names(), function (zoneName) {
var tz=moment.tz(zoneName);
timezoneMap[zoneName] = {
id: zoneName,
name: zoneName.replace(/_/g, ' '),
offset: 'UTC' + moment().tz(zoneName).format('Z')
offset: 'UTC' + tz.format('Z'),
nOffset: tz.utcOffset()
}
})
return timezoneMap
@@ -74,6 +76,8 @@ angular.module('angular-timezone-selector', [])
var zonesForCountry = {
text: CCToCountryName[CC] + ': ',
children: zonesByCountry
firstNOffset: zonesByCountry[0].nOffset,
firstOffset: zonesByCountry[0].offset
}
data.push(zonesForCountry)