Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify timezone in parser #22

Closed
eight04 opened this issue Mar 30, 2016 · 2 comments
Closed

Specify timezone in parser #22

eight04 opened this issue Mar 30, 2016 · 2 comments

Comments

@eight04
Copy link
Owner

eight04 commented Mar 30, 2016

The date filter in Angular now accept timezone argument. We should support it as well.
https://docs.angularjs.org/api/ng/filter/date

Maybe something like:

// different timezone will result in different datestring
parser.setDate(new Date);
datestring = parser.getText(timezone);

// if the timezone is not provided, it should look 'Z' token in datestring for the timezone.
parser.parse(datestring, timezone);
date = parser.getDate();
@eight04
Copy link
Owner Author

eight04 commented Mar 31, 2016

This is better for parsing:

parser.setTimezone(timezone);
parser.setDate(new Date); // always use time stamp of the date object
parser.getText();         // get different text under different timezone

parser.parse(datestring); // if datestring contains timezone definition 
                          // (i.e. 'Z' token), set timezone before parsing.
                          // result timestamp will be move to correct timezone.
parser.getDate();


           ---- parse -->            -- de-offset -->
datestring                dateobject                  realModel
           <-- getText --            <--- offset ----

Only create new Date in offset/de-offset phase.
Set timezone in parse phase.
Get timezone in getText phase.

@eight04
Copy link
Owner Author

eight04 commented Apr 1, 2016

Fixed in 3.0.0.

@eight04 eight04 closed this as completed Apr 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant