mirror of
https://github.com/wassname/angular-timezone-selector.git
synced 2026-06-27 17:47:05 +08:00
Added options for primary & local timezones, and show and sort by offset
This commit is contained in:
@@ -25,9 +25,34 @@ angular.module('timezoneSelectExample', ['angular-timezone-selector']);
|
||||
Then use directive `timezone-selector`.
|
||||
|
||||
```html
|
||||
<timezone-selector ng-model="timezone">
|
||||
<timezone-selector ng-model="timezone"><timezone-selector ng-model="timezone"></timezone-selector>
|
||||
```
|
||||
|
||||
## 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
|
||||
<timezone-selector
|
||||
ng-model="timezone"
|
||||
display-utc="true"
|
||||
sort-by="offset"
|
||||
show-local="true"
|
||||
primary-choices="UTC GB WET GMT Asia/Macau"
|
||||
></timezone-selector>
|
||||
```
|
||||
|
||||
## Screenshot
|
||||
The screenshot below show angular-selector in action with all options enabled:
|
||||
<img src="./images/primary_local_selection.png" alt-text="Angular-selector in action with all options enabled"></img>
|
||||
|
||||
# Attributions
|
||||
Inspired by [angular-timezone-select](https://github.com/alexcheng1982/angular-timezone-select) from [alexcheng1982](https://github.com/alexcheng1982).
|
||||
|
||||
|
||||
Vendored
+5
-1
@@ -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)
|
||||
|
||||
+4
-1
@@ -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 <ashok@mish.guru>"
|
||||
@@ -29,5 +29,8 @@
|
||||
"lodash": "~3.9.3",
|
||||
"chosen": "~1.4.2",
|
||||
"bootstrap": "~3.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jsTimezoneDetect": "latest"
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
+1
-1
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user