473,563 Members | 2,767 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Realtime clock that understands DST

Daz
Hi everyone.

I am trying to find out how I can create a real time clock, which
knows when to set itself backwards or forwards 1 hour. The clock will
work for various timezones. Some of which will not support DST.

If anyone has any suggestions as to how I might be able to achieve
this, I would very much appreciate it.

Jul 13 '07 #1
7 3130
On Jul 13, 10:08 am, Daz <cutenfu...@gma il.comwrote:
Hi everyone.

I am trying to find out how I can create a real time clock, which
knows when to set itself backwards or forwards 1 hour. The clock will
work for various timezones. Some of which will not support DST.

If anyone has any suggestions as to how I might be able to achieve
this, I would very much appreciate it.
If you're lucky, perhaps there is a time server on the 'net that
provides its services with an http interface.

Jul 13 '07 #2
Daz
On Jul 13, 3:12 pm, enrique <enrique.pin... @gmail.comwrote :
On Jul 13, 10:08 am, Daz <cutenfu...@gma il.comwrote:
Hi everyone.
I am trying to find out how I can create a real time clock, which
knows when to set itself backwards or forwards 1 hour. The clock will
work for various timezones. Some of which will not support DST.
If anyone has any suggestions as to how I might be able to achieve
this, I would very much appreciate it.

If you're lucky, perhaps there is a time server on the 'net that
provides its services with an http interface.
I was kind of hoping that, although I don't think I'd be able to
connect through Ajax due to cross-domain restrictions. I guess what I
should do really, is create one, that hands back a JavaScript time
object for the specified time zone.

I think the question I am really asking, is how can I find out when
the clocks go back or forwards next, automatically. I'm currently
trying to figure out how I can do this easily with PHP. I'm convinced
there is an easy way, that doesn't involved honing in on it with a
loop.

Jul 13 '07 #3
enrique wrote on 13 jul 2007 in comp.lang.javas cript:
On Jul 13, 10:08 am, Daz <cutenfu...@gma il.comwrote:
>Hi everyone.

I am trying to find out how I can create a real time clock, which
knows when to set itself backwards or forwards 1 hour. The clock will
work for various timezones. Some of which will not support DST.

If anyone has any suggestions as to how I might be able to achieve
this, I would very much appreciate it.

If you're lucky, perhaps there is a time server on the 'net that
provides its services with an http interface.
On the other hand, it can easily be done using javascript.
I would say to the OP:

Start [learning javascript and] start building.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 13 '07 #4
Daz
On Jul 13, 3:30 pm, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
enrique wrote on 13 jul 2007 in comp.lang.javas cript:
On Jul 13, 10:08 am, Daz <cutenfu...@gma il.comwrote:
Hi everyone.
I am trying to find out how I can create a real time clock, which
knows when to set itself backwards or forwards 1 hour. The clock will
work for various timezones. Some of which will not support DST.
If anyone has any suggestions as to how I might be able to achieve
this, I would very much appreciate it.
If you're lucky, perhaps there is a time server on the 'net that
provides its services with an http interface.

On the other hand, it can easily be done using javascript.
I would say to the OP:

Start [learning javascript and] start building.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
But "how"? lol

I've been working JavaScript for about a year now, but time zones are
unfamiliar territory. JavaScript doesn't really have the time zone
support I'd hoped for, so we have to work with offsets. Working with
offsets is not a problem. Knowing when to set a clock forwards or
backwards for time zone other than the one the client machine is at,
is not so easy. To my knowledge, this is impossible without some kind
of JavaScript NTP server. If you believe it is possible, I would very
much like to know how this can be done.

Jul 13 '07 #5
Daz wrote on 13 jul 2007 in comp.lang.javas cript:
On Jul 13, 3:30 pm, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
>enrique wrote on 13 jul 2007 in comp.lang.javas cript:
On Jul 13, 10:08 am, Daz <cutenfu...@gma il.comwrote:
Hi everyone.
>I am trying to find out how I can create a real time clock, which
knows when to set itself backwards or forwards 1 hour. The clock
will work for various timezones. Some of which will not support
DST.
>If anyone has any suggestions as to how I might be able to achieve
this, I would very much appreciate it.
If you're lucky, perhaps there is a time server on the 'net that
provides its services with an http interface.

On the other hand, it can easily be done using javascript.
I would say to the OP:

Start [learning javascript and] start building.

But "how"? lol

I've been working JavaScript for about a year now, but time zones are
unfamiliar territory. JavaScript doesn't really have the time zone
support I'd hoped for, so we have to work with offsets. Working with
offsets is not a problem. Knowing when to set a clock forwards or
backwards for time zone other than the one the client machine is at,
is not so easy. To my knowledge, this is impossible without some kind
of JavaScript NTP server. If you believe it is possible, I would very
much like to know how this can be done.

Knowing the UTC methods of JS:

getTimezoneOffs et()
getUTCDate()
getUTCDay()
getUTCFullYear( )
getUTCHours()
getUTCMilliseco nds()
getUTCMinutes()
getUTCMonth()
getUTCSeconds()
setUTCDate()
setUTCFullYear( )
setUTCHours()
setUTCMilliseco nds()
setUTCMinutes()
setUTCMonth()
setUTCSeconds()
UTC()

is always a great way to start.

The internal MS-Windows regional settings datafile for other timezones
is not available to clientside js, so you would have to build your own
data concerning the beginning and the end of summertime [in us-slang:
DST]

Adding an hour to time works like this:

d = new Date();

var diffHours = 1;

newTime = d.getTime() + diffHours * 60000);
Some of the John Stockton's Date/Time files seem not online,
but these are:

http://www.merlyn.demon.co.uk/js-dates.htm
http://www.merlyn.demon.co.uk/uksumtim.htm
http://www.merlyn.demon.co.uk/misctime.htm

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 13 '07 #6
Daz
On Jul 13, 4:34 pm, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
Daz wrote on 13 jul 2007 in comp.lang.javas cript:
On Jul 13, 3:30 pm, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
enrique wrote on 13 jul 2007 in comp.lang.javas cript:
On Jul 13, 10:08 am, Daz <cutenfu...@gma il.comwrote:
Hi everyone.
I am trying to find out how I can create a real time clock, which
knows when to set itself backwards or forwards 1 hour. The clock
will work for various timezones. Some of which will not support
DST.
If anyone has any suggestions as to how I might be able to achieve
this, I would very much appreciate it.
If you're lucky, perhaps there is a time server on the 'net that
provides its services with an http interface.
On the other hand, it can easily be done using javascript.
I would say to the OP:
Start [learning javascript and] start building.
But "how"? lol
I've been working JavaScript for about a year now, but time zones are
unfamiliar territory. JavaScript doesn't really have the time zone
support I'd hoped for, so we have to work with offsets. Working with
offsets is not a problem. Knowing when to set a clock forwards or
backwards for time zone other than the one the client machine is at,
is not so easy. To my knowledge, this is impossible without some kind
of JavaScript NTP server. If you believe it is possible, I would very
much like to know how this can be done.

Knowing the UTC methods of JS:

getTimezoneOffs et()
getUTCDate()
getUTCDay()
getUTCFullYear( )
getUTCHours()
getUTCMilliseco nds()
getUTCMinutes()
getUTCMonth()
getUTCSeconds()
setUTCDate()
setUTCFullYear( )
setUTCHours()
setUTCMilliseco nds()
setUTCMinutes()
setUTCMonth()
setUTCSeconds()
UTC()

is always a great way to start.

The internal MS-Windows regional settings datafile for other timezones
is not available to clientside js, so you would have to build your own
data concerning the beginning and the end of summertime [in us-slang:
DST]

Adding an hour to time works like this:

d = new Date();

var diffHours = 1;

newTime = d.getTime() + diffHours * 60000);

Some of the John Stockton's Date/Time files seem not online,
but these are:

http://www.merlyn.demon.co.uk/js-dat...k/misctime.htm

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
I was aware of the UTC function within JavaScript, I was just unsure
about how to know when to set the clocks backwards or forwards.

Thanks for the URLs, they are very helpful. I think I am going to look
into a PHP solution which others can use, which will send a JavaScript
object/array containing information about a particular time zone, such
as if DST is currently used, when the clock goes back/forward next,
and when.

Thanks again.

Jul 13 '07 #7
Daz wrote on 13 jul 2007 in comp.lang.javas cript:
Thanks for the URLs, they are very helpful. I think I am going to look
into a PHP solution which others can use, which will send a JavaScript
object/array containing information about a particular time zone, such
as if DST is currently used, when the clock goes back/forward next,
and when.
On the serverside, using asp:

I have websites for the Netherlands on servers in Toronto,
so I use this conversion include,
using serverside j[ava]script to determine the timeoffset,
and vbscript for the rest.

I do no need any knowledge about Canadian DST switch data/times,
and Central European Time quirks are wellknown over here.

Now is Toronto local time.
nuGMT is UTC.
nu is Central European local time.
nudag is the local time string.

=============== =============== =============
<% ' vbscript
nuGMT = DateAdd("h", TimezoneOffset, Now)
nu = DateAdd("h", 1, nuGMT)
If nuGMT>#2007-03-25 01:00# then nu = DateAdd("h", 2, nuGMT)
If nuGMT>#2007-10-28 01:00# then nu = DateAdd("h", 1, nuGMT)
If nuGMT>#2008-03-30 01:00# then nu = DateAdd("h", 2, nuGMT)
If nuGMT>#2008-10-26 01:00# then nu = DateAdd("h", 1, nuGMT)

nudag = day(nu) & "/" & month(nu) & " " & right("0"&hour( nu),2) & ":" &
right("0"&minut e(nu),2) & ":" & right("0"&secon d(nu),2)
%>

<script language='jscri pt' runat='server'>
var TimezoneOffset = new Date().getTimez oneOffset()/60;
</script>
=============== =============== =============

John Stockton wrote a computed European switch rule code here:

http://groups.google.c om/group/comp.lang.javas cript/msg/858cf852a991445 c>

In js-date5.htm (M=3 or M=10) :

function EUch(Y, M) { // return ms of Spring/Autumn EU clock change
var J = Date.UTC(Y, M-1, 31) // last of month is 31st, get UTC
return J - 864e5*((4+J/864e5)%7) + 36e5 /* Sun, 0100 GMT, ms */
}

[Not tested now]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 13 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6688
by: James Harriman | last post by:
Hi, I need to be able to measure a time interval in milliseconds on a windows machine. I have tried using time.clock() but it appears to measure time in seconds...Is there a way to measure time more precisely? Regards, James Harriman v38zy@unb.ca
0
408
by: Peger, Daniel H. | last post by:
Hi, I'm having a slight problem with the precision of the standard c++ clock function as it is defined in time.h . On my system the shortest meassurable time period is 0.01 seconds, but for my programm I need to meassure the processing time in ms. Is there perhaps something like an environment variable controlling the precision of...
33
47589
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
10
2534
by: Rafa³ | last post by:
Hi. Timer in C# not work, Thread + Loop + Sleep + DateTime.Now too not work (Process.Prioritet = RealTime) What i do wrong? Best regards. Rafal
6
6316
by: aikwee | last post by:
is it possible to make a thread priority to realtime mode in vb.net ?
54
3970
by: CoreyWhite | last post by:
The following experiment is a demonstration of TIME TRAVEL. When writing this program, and testing it out I found that sometimes the program would engage itself in time travel but other times it would not. After careful testing and reprogramming I have optimized the code so it should work every time, however I recommend that you leave the...
5
4901
by: zl2k | last post by:
hi, all I am trying to moniter the runing of a program by printing out some characters in a line at each stage. say, //program part1 cout<<"part1 "; //program part2 cout<<part2 "; ....
12
4074
by: cenktarhancenk | last post by:
is there a way to display a ticking clock in a web page using javascript? but not in a textbox, rather as text that i can change the style, font etc. cenk tarhan
5
6924
by: none | last post by:
Hello, can you help? if I include: #include <time.h> and run the code: clock_t t = clock(); cout << "t is " << t << endl; I get (seemingly randomly) "t is 0" or "t is 10000"
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.