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

Add function toTimeZone #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

nev-tuannm4
Copy link

Parse time to expected time zone.

Example:
toTimeZone('2017/01/01 00:00:00Z', 'Asia/Tokyo')
=> 2017/01/01 09:00:00

Parse time to expected time zone.

Example:
toTimeZone('2017/01/01 00:00:00Z', 'Asia/Tokyo')
=> 2017/01/01 09:00:00
@phstc
Copy link
Owner

phstc commented Nov 15, 2017

Hi @nev-tuannm4

Thanks for the contribution 🍻

Would you mind adding some test cases?

https://github.com/phstc/jquery-dateFormat/tree/master/test

@nev-tuannm4
Copy link
Author

I have upload some test case for toTimeZone function. Please check new pull request.
Ist all most use function of format date so i don't test again.

@phstc
Copy link
Owner

phstc commented Dec 1, 2017

Hi @nev-tuannm4

Can you merge the tests #106 with in the same PR #104 with the implementation?

// timeZone : Asia/Tokyo etc..
// clear LRM in IE
var date = new Date(value).toLocaleString('en-US', {timeZone: timeZone, hour12: false}).replace(/‎|\u200E/gi, '');
return this.date(new Date(date), format || 'MM/dd/yyyy HH:mm:ss');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nev-tuannm4 could you move the change to https://github.com/phstc/jquery-dateFormat/blob/master/src/dateFormat.js, this dist/jquery-dateFormat.js is the compiled file.

@nikowuesti
Copy link

I needed the toTimeZone function quite recently and implemented this PR, but I had to change "hour12: false" to "hourCycle: 'h23'" to make it work.

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

Successfully merging this pull request may close these issues.

3 participants