Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(input): allow to define the timezone when parsing and formatting dates #8629

Merged
merged 0 commits into from
Aug 26, 2014

Conversation

tbosch
Copy link
Contributor

@tbosch tbosch commented Aug 15, 2014

Allow to define the timezone for parsing dates in input[date], input[time], … as well as in the dateFilter.

Closes #8447.

@tbosch
Copy link
Contributor Author

tbosch commented Aug 15, 2014

@petebacondarwin Could you review this PR and merge it if good?

@tbosch tbosch added this to the 1.3.0 milestone Aug 15, 2014
@petebacondarwin
Copy link
Contributor

@tbosch - is there a reason why some tests use Date.UTC and some +Date.UTC?

@estekhin
Copy link

@tbosch

I would say that the L1040 map = { yyyy: 0, MM: 1, dd: 1, HH: 0, mm: 0 }; should instead be map = { yyyy: 1970, MM: 1, dd: 1, HH: 0, mm: 0 }; to be inline with html spec.

The similar correction should be done somewhere near the first change - the base year value should be 1970 instead of 0 which means 1900.

@petebacondarwin
Copy link
Contributor

@estekhin - how come that doesn't fail any of the tests then?

@tbosch
Copy link
Contributor Author

tbosch commented Aug 16, 2014

@petebacondarwin No, the old code contained them for converting a Date into a number and I forgot to remove them, as Date.UTC already returns a number.

@tbosch
Copy link
Contributor Author

tbosch commented Aug 16, 2014

The tests are failing, will look into this on Monday...

@estekhin
Copy link

@petebacondarwin base year=1970 is needed for input[time]. What is the policy on that - should I create an issue specific for input[time]?

The idea is that when converting a string value of input[time] into a Date it should be based on 1970-01-01 "date" part as described in http://www.w3.org/TR/html5/forms.html#time-state-(type=time) and http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#time-state-(type=time).
Also input[time] should support seconds, but the current definition in the form of 'time': createDateInputType('time', TIME_REGEXP, createDateParser(TIME_REGEXP, ['HH', 'mm']), 'HH:mm'), stops at minutes.

@tbosch
Copy link
Contributor Author

tbosch commented Aug 18, 2014

I will include it in this PR...

@tbosch tbosch force-pushed the inputdate branch 2 times, most recently from 023fab7 to 9c0d485 Compare August 25, 2014 18:26
@tbosch tbosch changed the title fix(input): use UTC when parsing dates feat(input): allow to define the timezone when parsing and formatting dates Aug 25, 2014
@tbosch
Copy link
Contributor Author

tbosch commented Aug 25, 2014

@petebacondarwin Could you review this?

@IgorMinar IgorMinar modified the milestones: 1.3.0, 1.3.0-rc.0 Aug 25, 2014
@petebacondarwin
Copy link
Contributor

This seems OK. I wonder though whether UTC should be the default? Since that is how HTML5 API inputs are supposed to work?

@tbosch
Copy link
Contributor Author

tbosch commented Aug 26, 2014

@petebacondarwin see the comment on the issue that I am about to add :-)

@tbosch tbosch force-pushed the inputdate branch 3 times, most recently from e94ab96 to 5f90340 Compare August 26, 2014 21:21
@tbosch tbosch merged commit 5f90340 into angular:master Aug 26, 2014
@tbosch tbosch deleted the inputdate branch August 28, 2014 16:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1.3.0 input[date] model is a Date object in local time zone instead of UTC
5 participants