eight04 / angular-datetime

A directive to add the behavior of datetime input on unsupported browsers.
MIT License
93 stars 28 forks source link

datetime-utc dynamically #29

Closed crazyjat closed 8 years ago

crazyjat commented 8 years ago

I need the ability to display the time in local time or utc based on a user selection. Is there currently a way to dynamically change the timezone of the input field?

eight04 commented 8 years ago

Currently, no. The timezone is set when linked: https://github.com/eight04/angular-datetime/blob/master/src/directive.js#L199 . It is like a switch to change between input[datetime] and input[datetime-local]. (Note that there is no browser supporting datetime: https://github.com/whatwg/html/issues/336)

Should we implement it?

crazyjat commented 8 years ago

For now i am using ng-if to switch between 2 versions of the directive, which is not ideal. I might do a pull to add support for it dynamically. It would be very useful if the datetime-utc directive could be triggered by a property.

eight04 commented 8 years ago

Maybe we can create a binding ($watch) if attrs.datetimeUtc is a string and length > 0.

<input ... datetime-utc="aVar">

Then we create a binding to scope.aVar.

eight04 commented 8 years ago

https://github.com/eight04/angular-datetime/compare/dev-dynamic-utc

Try the demo: https://rawgit.com/eight04/angular-datetime/dev-dynamic-utc/example/demo.html

eight04 commented 8 years ago

Fixed in 3.2.0.