Author Topic: Present Time  (Read 13046 times)

Offline Richard

  • Newbie
  • *
  • Posts: 44
    • View Profile
Present Time
« on: September 01, 2007, 03:40:44 AM »
The "Present Time" box of the "µTasker - administration" side web page <.../5admin.htm> doesn't display the current time unless both USE_TIME_SERVER and SUPPORT_LCD constants have been defined.  You need SUPPORT_LCD even if you don't have an LCD attached.

The time shown (in the summer) is the time in London, not UT (a.k.a. GMT).  In the winter, I guess the time shown would be the time in Switzerland.  In any case, to set the time to Eastern Daylight Time (my local time, five hours behind London), I've added two lines to application.c:
       #define TIMEZONE (-5*60*60)
near where REL_9_1_2007 is defined (though it should probably be in config.h) and added
        ulPresentTime += TIMEZONE;
just after the line
        ulPresentTime -= REL_9_1_2007;                                   // relative to 0:0:0 on 9.1.2007

Best regards,
    Richard

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Present Time
« Reply #1 on: September 02, 2007, 04:53:10 PM »
Hi Richard

I just tested and didn't need to set the LCD define to get the time to be displayed correcty.
I wonder whether the Time Server didn't respond when you did the test the first time (sometimes this happens but on the second attempt it is OK).

The time server delivers the number of elapsed seconds since a certain point in time (I think the first second of 1900).
    #define REL_9_1_2007           (unsigned long)0xc94d4b7b

On this day (9.1.2007) I simply ran the demo and looked at the number of seconds the server gave back. Then I corrected back to midnight and set the define. Of course I did it to local time (GMT + 1h) and so in summer time it is exactly one hour behind. Your correction to your local time is correct - although a neat way to do it would be to add the correction (from GMT) into the user parameter block so that this can be a user configuration (rather than define)...
By using Browser time zone information it could possibly be displayed automatically corrected on the administrator page!

The SP5 adds RTC support and so it would be possible to synchronise the RTC to the collected time.
Leon Y. was kind enough to send me the code to convert the seconds to Gregorian data (respecting leap years, day of week etc.) but I didn't have the chance to test it before the SP5 release. But this would allow the day and date to be extracted from the the Time Server seconds value, the RTC to be set and then full calendar support would be available for applications (each midnight RTC interrupt could be used to adjust month lengths when necessary) - the only thing that is not automatic is the summer/winter time shift but this if generally the case for any realisation; it is usually up to the user to adjust it accordingly.

Regards

Mark
« Last Edit: September 03, 2007, 04:50:29 PM by mark »

Offline Richard

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Present Time
« Reply #2 on: September 03, 2007, 12:14:06 AM »
I just tested and didn't need to set the LCD define to get the time to be displayed correcty.
I wonder whether the Time Server didn't respond when you did the test the first time (sometimes this happens but on the second attempt it is OK).

Hmmm...I thought I tried it more than once, but I'll try it again in a week when I get back from this trip.

Quote
The time server delivers the number of elapsed seconds since a certain point in time (I think the first second of 1900).
    #define REL_9_1_2007           (unsigned long)0xc94d4b7b

On this day (9.1.2007) I simply ran the demo and looked at the number of seconds the server gave back.

I noticed the date, but forgot that it wasn't being written in the nutty US way; i.e., I interpreted it as 1 September 2007 rather than 9 January 2007. It doesn't really matter in this case, though I did briefly wonder why you'd chosen a date in the future and what would happen on 1 September. [Aside - totally irrelevant to this, but maybe an interesting anecdote: It did, once, make a mess of a graphing program that was using the Windows system time as the x-axis. A customer in Quebec had a machine that was originally configured for French and then back to English, and the internally reported time, as used in the program, calculated that the difference between 23:59 on 3.5 to 00:00 on 3.6 was a month rather than a minute, stretching the graph accordingly.  It was quite the mystery until the 13th of the month, when we were told that the date was illegal.]

Quote
Your correction to your local time is correct - although a neat way to do it would be to add the correction (from GMT) into the user parameter block so that this can be a user configuration (rather than define)...
By using Browser time zone information it could possibly be displayed automatically corrected on the administrator page!

Yes, but I'm too new at using this system to have figured out how to use the user parameter block already.

Quote
... But this would allow the day, date to be extracted from the the Time Server seconds value, the RTC set be set and then full calendar support would be available for applications - the only thing that is not automatic is the summer/winter time shift but this if generally the case for and realisation; it is usually up to the user to adjust it accordingly.

I'm looking forward to this; but for my purposes right now, local time (or even UT) accurate to the minute is probably good enough.

Best regards,
    Richard