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

beforeDateTime and tzoneOffset #8

Open
AlexanderSk opened this issue Oct 1, 2015 · 1 comment
Open

beforeDateTime and tzoneOffset #8

AlexanderSk opened this issue Oct 1, 2015 · 1 comment

Comments

@AlexanderSk
Copy link

Hello,

I can you please check, support the option tzoneOffset along beforeDateTime.

Currently these two scripts show the exact same time.

$('#retroclockbox1').flipcountdown({
beforeDateTime:'10/20/2015 11:00:00',
tzoneOffset: 2
});

$('#retroclockbox2').flipcountdown({
beforeDateTime:'10/20/2015 11:00:00',
tzoneOffset: 3
});

I found a few time in order to fix it and i came with the following modification:
Line 187 options.beforeDateTime = Math.round((new Date(options.beforeDateTime)).getTime()/1000);

I placed for a test...

if(options.tzoneOffset){
//get current local time
var tmp = new Date(options.beforeDateTime).getTime();
//get current local time offset
var localoffset = new Date(options.beforeDateTime).getTimezoneOffset();
//find the difference between offsets
var offsetdif = ( (options.tzoneOffset * 60) + localoffset ) / 60;
//place the date in a var
tmp = (new Date(options.beforeDateTime)).getTime() - 3600000 * (offsetdif)
options.beforeDateTime = Math.round(tmp/1000);
}else{
options.beforeDateTime = Math.round((new Date(options.beforeDateTime)).getTime()/1000);
}

This covers the string and not the object case of course... but is is something :)
Unfortunately there is no easy way in javascript to convert a date into specific timezoneoffset.

Thank you for your time!

Edit: 6-10-2015.

@filipemontt
Copy link

how to stop countdown?

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

2 participants