diff --git a/README.md b/README.md index 73e953d..6b4415a 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,34 @@ angular.module('timezoneSelectExample', ['angular-timezone-selector']); Then use directive `timezone-selector`. ```html - + ``` +## Options + +Options can be included as attributes in the html element. + + - **sort-by** ["offset"] - This lets the list be sorted by UTC offset instead of alphabetical order. + - **display-utc** ["true"] - This show UTC offsets in the timezone names + - **show-local** ["true"] - This detects local timezone's and includes at the top. If jsTimezoneDetect is installed if will include the detected timezone otherwise it fallback on moment js and list all timezones with the same browsers UTC offset. + - **primary-choices** ["space seperated timezone names"] - This lets you put important timezone's at the top of the list or include extra aliases. Use names from momentjs-timezone, which you can list with the command: `moment.tz.names;`. + +An example of using the options is below: + +```html + +``` + +## Screenshot +The screenshot below show angular-selector in action with all options enabled: + + # Attributions Inspired by [angular-timezone-select](https://github.com/alexcheng1982/angular-timezone-select) from [alexcheng1982](https://github.com/alexcheng1982). diff --git a/angular-timezone-selector.js b/angular-timezone-selector.js index e1d52d4..10bed6c 100644 --- a/angular-timezone-selector.js +++ b/angular-timezone-selector.js @@ -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) diff --git a/bower.json b/bower.json index 2238e4f..d55a9a4 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-timezone-selector", - "version": "1.1.0", + "version": "1.2.0", "homepage": "https://github.com/mishguruorg/angular-timezone-selector", "authors": [ "Ashok Fernandez " @@ -29,5 +29,8 @@ "lodash": "~3.9.3", "chosen": "~1.4.2", "bootstrap": "~3.3.4" + }, + "devDependencies": { + "jsTimezoneDetect": "latest" } } diff --git a/images/primary_local_selection.png b/images/primary_local_selection.png new file mode 100644 index 0000000..40bdede Binary files /dev/null and b/images/primary_local_selection.png differ diff --git a/package.json b/package.json index 3bff727..3f55436 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-timezone-selector", - "version": "1.0.1", + "version": "1.2.0", "description": "AngularJS timezone selector", "main": "dist/angular-timezone-selector.min.js", "scripts": {