Skip to content
This repository has been archived by the owner on Oct 29, 2018. It is now read-only.

Commit

Permalink
Merge pull request #18 from tiagotex/master
Browse files Browse the repository at this point in the history
Add option to set ngModel as local timezone
  • Loading branch information
ashokfernandez committed Dec 1, 2015
2 parents a8bce20 + 7ea481b commit 12329dd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ 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.
- **set-local** ["true"] - This sets ngModel to detected timezone if it's not set yet. jsTimezoneDetect must be installed for this option to work.
- **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;`.
- **width** - Sets the width of the element

An example of using the options is below:

```html
Expand All @@ -53,6 +54,7 @@ An example of using the options is below:
display-utc="true"
sort-by="offset"
show-local="true"
set-local="true"
primary-choices="UTC GB WET GMT Asia/Macau"
width="400px"
></timezone-selector>
Expand Down
6 changes: 6 additions & 0 deletions angular-timezone-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ angular.module('angular-timezone-selector', [])
})
}

if (attrs.setLocal !== undefined) {
if (jstz !== undefined) {
$scope.ngModel || ($scope.ngModel = jstz.determine().name())
}
}

// add initial options
if (attrs.primaryChoices !== undefined) {
// var primaryChoices=['UTC','GB','WET','GMT','Asia/Macau']
Expand Down
6 changes: 6 additions & 0 deletions build/angular-timezone-selector.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions dist/angular-timezone-selector.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/angular-timezone-selector.min.js

Large diffs are not rendered by default.

0 comments on commit 12329dd

Please sign in to comment.