Time zone and Internet date

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Time zone and Internet date

Post by trevix » Fri Aug 07, 2009 4:21 pm

I was having problem with time zone so I did a little investigation:
On a Mac I did a little script:

Code: Select all

on mouseUp
   put 86400 into theHour
   convert thehour to dateitems
   put thehour into hour2
   convert hour2 to seconds
   put last word of the internet date into timez
   put "time zone: " & timez  & return & "the seconds: " & hour2 & return & "converted to dateitems: " & thehour & return & return after fld "fld3"
end mouseUp
Changing everytime the time zone on the Control panel, running the script and saving i came up with this list:
time zone: +0600
the seconds: 86400
converted to dateitems: 1970,1,2,5,0,0,6

time zone: +0500
the seconds: 86400
converted to dateitems: 1970,1,2,5,0,0,6

time zone: +0400
the seconds: 86400
converted to dateitems: 1970,1,2,3,0,0,6

time zone: +0300
the seconds: 86400
converted to dateitems: 1970,1,2,2,0,0,6

time zone: +0200
the seconds: 86400
converted to dateitems: 1970,1,2,1,0,0,6

time zone: +0100
the seconds: 86400
converted to dateitems: 1970,1,2,1,0,0,6

time zone: +0000
the seconds: 86400
converted to dateitems: 1970,1,2,0,0,0,6

time zone: -0200
the seconds: 86400
converted to dateitems: 1970,1,1,21,0,0,5

time zone: -0300
the seconds: 86400
converted to dateitems: 1970,1,1,21,0,0,5

time zone: -0400
the seconds: 86400
converted to dateitems: 1970,1,1,20,0,0,5

time zone: -0500
the seconds: 86400
converted to dateitems: 1970,1,1,19,0,0,5

time zone: -0600
the seconds: 86400
converted to dateitems: 1970,1,1,17,0,0,5

time zone: -0700
the seconds: 86400
converted to dateitems: 1970,1,1,16,0,0,5

time zone: -0800
the seconds: 86400
converted to dateitems: 1970,1,1,14,0,0,5

As you can see, the thing is not linear. Can some one tell me why ?

Further:
With the clock showing the same time, but changing time zone, I've got this

CEST time zone: +0200
the seconds: 86400
converted to dateitems: 1970,1,2,1,0,0,6

EET time zone: +0200
the seconds: 86400
converted to dateitems: 1970,1,2,2,0,0,6

May be I did not understand the time zone business...[/i]

trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Post by trevix » Sun Aug 09, 2009 5:14 pm

Anyone ?
I believe could be a matter of Legal hour...but I do not know how Rev could get to it
What I need is a way to transform a date from one time zone to another time zone, getting the time zone from the system on wich the computer is run (I guessed the last word of the internet time).

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Aug 09, 2009 6:44 pm

Trevix,

Are time zones linear?

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Post by trevix » Sun Aug 09, 2009 9:46 pm

Well, if the Rev "internet date" give me a +0400 and some converted seconds give the time 03:00 (as for my example) , I think that for a Rev "internet date" of +0500 the same converted seconds should give me the time 04:00, not 05:00.
Right ?
Unless there is the Daylight Saving Time to take in account...

The point is: can I be sure that I can use a calculation based on the Rev internet date TZ to enable two application, located in different time zone may be with different Daylight saving, to know each other time ?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Aug 09, 2009 10:15 pm

Hi Trevis,

In previous versions of Revolution, there were issues with time conversion. I believe that most problems have been solved, but you can't be sure without testing it yourself.

Time zones +5 and +6 are problematic. Are you sure you chose a full +6 and not +5.30 or +5.45? There is also a +6.30. So, be careful here. You should probably read up on time zones.

When a computer uses its own time to determine the time on another computer, while its clock has been set incorrectly, it will calculate an incorrect time for the other computer. Therefore, you might want to connect to a network time server. You'll find a small library that uses Network Time Protocol over Telnet here.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Post by trevix » Sun Aug 09, 2009 10:45 pm

Thanks.
I could just ask the users to setup their clock to automatically use the network time server (both OX and Win have this default in the control panel).

In this way, supposing that the clock is set correctely, will the Rev internet date Time zone be trustefull or, as you suggested, is better to use the library for network time server ?

Post Reply