I wasn't sure where to post this question so I posted it to both locations.
I'm using a stock MOD-5270 module for my web server application which means no RTC chip. Instead I'm using the system clock for my purposes. My question is if I set the use daylight saving flag in the time calls will the system clock adjust itself accordingly when the time changes? I think the answer is no but I want to be sure.
Craig Lindley
Daylight savings time and the system clock
-
- Posts: 19
- Joined: Sat Apr 26, 2008 6:19 am
Re: Daylight savings time and the system clock
Hi Craig,
I think the answer is no. Have you looked into adding a RTC on your board?
I think the answer is no. Have you looked into adding a RTC on your board?
- Brian Click
- Posts: 10
- Joined: Tue Sep 02, 2008 2:00 pm
- Location: Chicago Area
Re: Daylight savings time and the system clock
This is an old thread but...
You could call a JS function, to get the user's PC timezone, through the browser, into form elements (or other DOM objects just the same):
and apply that offset to all displayed times in your UI. That way users anywhere will see the correctly adjusted time.
I assume you're "occasionally" getting the correct time from a NTP server, to sync the system clock. If you're using the user's PC clock to sync the NB system clock, then you can do it all within the same function, by fleshing it out, something like this:
hope it helps someone
You could call a JS function, to get the user's PC timezone, through the browser, into form elements (or other DOM objects just the same):
Code: Select all
function getpctime()
{
var t = new Date();
document.my_form.GMT_OFFSET.value = (t.getTimezoneOffset()/60)*-1; //timezone according to PC
}
I assume you're "occasionally" getting the correct time from a NTP server, to sync the system clock. If you're using the user's PC clock to sync the NB system clock, then you can do it all within the same function, by fleshing it out, something like this:
Code: Select all
function getpctime()
{
var t = new Date();
document.my_form.YEAR.value = t.getFullYear();
document.my_form.MONTH.value = fixNumber( t.getMonth() +1); // January is month 0
document.my_form.DAY.value = fixNumber( t.getDate() );
document.my_form.HOUR.value = fixNumber( t.getHours() );
document.my_form.MINUTE.value = fixNumber( t.getMinutes() );
document.my_form.SECOND.value = fixNumber( t.getSeconds() );
document.my_form.GMT_OFFSET.value = (t.getTimezoneOffset()/60)*-1;
}
//need this function too
function fixNumber(the_number)
{
if (the_number < 10)
{
the_number = "0" + the_number;
}
return the_number;
}