Comments (7)
I'm not sure what you are going to achieve.
If you want to use 1976-11-14T07:05:58+01:00
as default value, you can convert the date string into a date object: https://plnkr.co/edit/9YRgQClGD9gpVQSeLlzT?p=preview
If you want to create a datetime input with specific timezone (+0100), currently you can't. There is only a datetime-utc
flag to use +0000 as timezone.
And here is why you got the date of the day:
- The parser raised mismatch error when parsing a date string with incorrect timezone.
- The directive tried to revert the input to previous state when getting a parsing error.
- The date was set to its initial value
new Date()
.
from angular-datetime.
After searching and testing, it seems parsing gets an error on timezone whenever it's not the default timezone or the one that is set. Getting this error message : Pattern value mismatch
Here is the test :
https://plnkr.co/edit/SBZDc5CaaFLsJ9eKzuAE?p=preview
from angular-datetime.
Converting my string into a date object will do it.
I guess parsing timezone is work in progress, maybe meanwhile it would be convenient to add a note in the readme about ZZ on this point ?
Thank you anyway for your reactivity and also for you work !
from angular-datetime.
There were some discussions to make timezone "editable", but this feature is rarely used. Most of the time we only save the date into database without timezone information, and display the date to users in their local timezone. If timezone information is needed, we use another field to record it.
However, it would be good if we can make timezone "parsable", which should work like this:
datestr = "1976-11-14T07:05:58+01:00";
parser = datetime("yyyy-MM-ddTHH:mm:ssZZ");
date = parser.parse(datestr, true).getDate(); // a flag allowing the parser to switch the timezone automatically
date.getTime() == new Date(datestr).getTime(); // true
parser.inTimezone("+01:00"); // true
from angular-datetime.
For information, we found a neat solution to handle the issue making a directive with $parsers and $formatters having a priority of 101 (superior to this library)
https://plnkr.co/edit/g2tPcae2mfdp3PHo9HZ1?p=preview
I guess this could be directly done inside the library.
from angular-datetime.
You will get the date in local timezone with that code, also the colon :
is missing.
If timezone doesn't matter, I would do something like this:
https://plnkr.co/edit/MRAoBt8Cam6YbmlvHgkb?p=preview
from angular-datetime.
Now you can use datetime-zone
to specify a custom timezone.
from angular-datetime.
Related Issues (20)
- Module 'custom-input' is not available HOT 7
- Placeholder HOT 2
- TypeError: date.getTime is not a function HOT 2
- Cursor jumps to end of input field on up/down keys HOT 12
- Compatibility with Angular UI Bootstrap DatePicker Popup HOT 2
- Object.values HOT 2
- Placeholder isn't actually a placeholder and no way to turn it off HOT 3
- Bug: set day HOT 8
- how can I reset placeholder HOT 1
- Any Way To Use Timezone Strings (UTC, EST)? HOT 1
- Unused property Element.handler HOT 1
- strictdi error on version 5.1.3 HOT 1
- Add bower support. HOT 1
- Incorrect Year when using shortDate format HOT 1
- it is no going through steps, it is just stay in days HOT 3
- IE 11 not supported HOT 4
- Create a new version for angular 2+ HOT 5
- Can't initialize control with anything but current date HOT 6
- Timestamp HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-datetime.