Hi all, Can anyone tell me why time.h states that we have 62 seconds in a minute? typedef struct tm { int tm_sec; // Seconds after the minute (0,61) int tm_min; // Minutes after the hour (0,59) int tm_hour; // hours since midnight (0,23) int tm_mday; // day of the month (1,31) int tm_mon; // moths since January (0,11) int tm_year; // years since 1900 int tm_wday; // days since Sunday (0,6) int tm_yday; // days since January 1 (0,365) int tm_isdst; // Daylight saving time flag 1= active 0= not active }; And how should this be implemented? Currently I thought like this: void rtcService(void) __interrupt[TIMERA0_VECTOR] { // check for overflows if(++RtcTime.tm_sec > 61) // Seconds after the minute (0,61) { RtcTime.tm_sec = 0; if(++RtcTime.tm_min > 59) // Minutes after the hour (0,59) { RtcTime.tm_min = 0; if(++RtcTime.tm_hour > 23) // Hours since midnight (0,23) { if(++RtcTime.tm_wday > 6) RtcTime.tm_wday = 0; // Days since Sunday (0,6) if(++RtcTime.tm_yday > 365) RtcTime.tm_yday = 0; // days since january 1 (0, 365) if(++RtcTime.tm_mday > MonthDayTable[RtcTime.tm_mon-1]) // Day of the month (1,31) { RtcTime.tm_mday = 1; if(++RtcTime.tm_mon > 11) // months since Januari (0,11) { RtcTime.tm_mon = 0; RtcTime.tm_year++; // Years since 1900 } } } } } }// (jump back into the program) But obviously this goes wrong. The thing is I need a unix like timer routine for calculations And I thought that time.c would be available on the web but so far no luck. If then I could check this and find out what/why im thinking wrong thanks martijn
time.h question
Started by ●November 13, 2004
Reply by ●November 13, 20042004-11-13
Hi Martijn, Try Googling for "leap seconds". I've needed to use leap seconds for contracts where broadcasters get very uptight about time issues. This is a good reference: http://tycho.usno.navy.mil/leapsec.html For those of you interested in time, the Standard C Date/Time Library book is interesting, but has bugs. http://www.amazon.com/exec/obidos/tg/detail/-/0879304960/102-5642561-486 1761?v=glance -- Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors > -----Original Message----- > From: martijnbroens@mart... [mailto:martijnbroens@mart...] > Sent: 13 November 2004 12:58 > To: msp430@msp4... > Subject: [msp430] time.h question > > > Hi all, > > > > Can anyone tell me why time.h states that we have 62 seconds > in a minute? > > > > typedef struct tm > > { > > int tm_sec; // Seconds after the minute (0,61) > > int tm_min; // Minutes after the hour (0,59) > > int tm_hour; // hours since midnight (0,23) > > int tm_mday; // day of the month (1,31) > > int tm_mon; // moths since January (0,11) > > int tm_year; // years since 1900 > > int tm_wday; // days since Sunday (0,6) > > int tm_yday; // days since January 1 (0,365) > > int tm_isdst; // Daylight saving time flag 1= active 0= not active > > }; > > > > And how should this be implemented? > > Currently I thought like this: > > void rtcService(void) __interrupt[TIMERA0_VECTOR] > > { > > // check for overflows > > if(++RtcTime.tm_sec > 61) // Seconds > after the minute > (0,61) > > { > > RtcTime.tm_sec = 0; > > if(++RtcTime.tm_min > 59) // Minutes > after the hour > (0,59) > > { > > RtcTime.tm_min = 0; > > if(++RtcTime.tm_hour > 23) // Hours since > midnight (0,23) > > { > > if(++RtcTime.tm_wday > 6) RtcTime.tm_wday = 0; // Days since > Sunday (0,6) > > if(++RtcTime.tm_yday > 365) RtcTime.tm_yday = 0; // > days since january 1 (0, 365) > > if(++RtcTime.tm_mday > > MonthDayTable[RtcTime.tm_mon-1]) // Day of the month (1,31) > > { > > RtcTime.tm_mday = 1; > > if(++RtcTime.tm_mon > 11) // months since Januari > (0,11) > > { > > RtcTime.tm_mon = 0; > > RtcTime.tm_year++; // Years since 1900 > > } > > } > > } > > } > > } > > }// (jump back into the program) > > > > But obviously this goes wrong. The thing is I need a unix > like timer routine for calculations > > And I thought that time.c would be available on the web but > so far no luck. > If then I could check this and find out what/why im thinking wrong > > > > thanks martijn > > > > > > > > > > ------------------------ Yahoo! Groups Sponsor > --------------------~--> > $9.95 domain names from Yahoo!. Register anything. > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/CFFolB/TM > -------------------------- > ------~-> > > . > > > Yahoo! Groups Links > > > > > > > > >
Reply by ●November 13, 20042004-11-13
Hi Paul, Thanks for the reply i'm checking it _____ From: Paul Curtis [mailto:plc@plc@...] Sent: zaterdag 13 november 2004 14:26 To: msp430@msp4... Subject: RE: [msp430] time.h question Hi Martijn, Try Googling for "leap seconds". I've needed to use leap seconds for contracts where broadcasters get very uptight about time issues. This is a good reference: http://tycho.usno.navy.mil/leapsec.html For those of you interested in time, the Standard C Date/Time Library book is interesting, but has bugs. http://www.amazon.com/exec/obidos/tg/detail/-/0879304960/102-5642561-486 1761?v=glance -- Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors > -----Original Message----- > From: martijnbroens@mart... [mailto:martijnbroens@mart...] > Sent: 13 November 2004 12:58 > To: msp430@msp4... > Subject: [msp430] time.h question > > > Hi all, > > > > Can anyone tell me why time.h states that we have 62 seconds > in a minute? > > > > typedef struct tm > > { > > int tm_sec; // Seconds after the minute (0,61) > > int tm_min; // Minutes after the hour (0,59) > > int tm_hour; // hours since midnight (0,23) > > int tm_mday; // day of the month (1,31) > > int tm_mon; // moths since January (0,11) > > int tm_year; // years since 1900 > > int tm_wday; // days since Sunday (0,6) > > int tm_yday; // days since January 1 (0,365) > > int tm_isdst; // Daylight saving time flag 1= active 0= not active > > }; > > > > And how should this be implemented? > > Currently I thought like this: > > void rtcService(void) __interrupt[TIMERA0_VECTOR] > > { > > // check for overflows > > if(++RtcTime.tm_sec > 61) // Seconds > after the minute > (0,61) > > { > > RtcTime.tm_sec = 0; > > if(++RtcTime.tm_min > 59) // Minutes > after the hour > (0,59) > > { > > RtcTime.tm_min = 0; > > if(++RtcTime.tm_hour > 23) // Hours since > midnight (0,23) > > { > > if(++RtcTime.tm_wday > 6) RtcTime.tm_wday = 0; // Days since > Sunday (0,6) > > if(++RtcTime.tm_yday > 365) RtcTime.tm_yday = 0; // > days since january 1 (0, 365) > > if(++RtcTime.tm_mday > > MonthDayTable[RtcTime.tm_mon-1]) // Day of the month (1,31) > > { > > RtcTime.tm_mday = 1; > > if(++RtcTime.tm_mon > 11) // months since Januari > (0,11) > > { > > RtcTime.tm_mon = 0; > > RtcTime.tm_year++; // Years since 1900 > > } > > } > > } > > } > > } > > }// (jump back into the program) > > > > But obviously this goes wrong. The thing is I need a unix > like timer routine for calculations > > And I thought that time.c would be available on the web but > so far no luck. > If then I could check this and find out what/why im thinking wrong > > > > thanks martijn > > > > > > > > > > ------------------------ Yahoo! Groups Sponsor > --------------------~--> > $9.95 domain names from Yahoo!. Register anything. > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/CFFolB/TM > -------------------------- > ------~-> > > . > > > > Terms of Service.
Reply by ●November 13, 20042004-11-13
Martijn, Unless you *need* to use leap seconds, you can ignore them--60 seconds to a minute, usually. Most people can go through their entire lifetime without every worrying about leap seconds. I don't have my copy of the SCDTL book handy, but I'm pretty sure it details leap seconds. -- Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors > -----Original Message----- > From: Martijn Broens [mailto:martijnbroens@mart...] > Sent: 13 November 2004 13:36 > To: msp430@msp4... > Subject: RE: [msp430] time.h question > > > Hi Paul, > > > > Thanks for the reply i'm checking it > > > > _____ > > From: Paul Curtis [mailto:plc@plc@...] > Sent: zaterdag 13 november 2004 14:26 > To: msp430@msp4... > Subject: RE: [msp430] time.h question > > > > Hi Martijn, > > Try Googling for "leap seconds". I've needed to use leap > seconds for contracts where broadcasters get very uptight > about time issues. > > This is a good reference: > > http://tycho.usno.navy.mil/leapsec.html > > For those of you interested in time, the Standard C Date/Time > Library book is interesting, but has bugs. > > http://www.amazon.com/exec/obidos/tg/detail/-/0879304960/102-5 > 642561-486 > 1761?v=glance > > -- > Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk > CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors > > > -----Original Message----- > > From: martijnbroens@mart... [mailto:martijnbroens@mart...] > > Sent: 13 November 2004 12:58 > > To: msp430@msp4... > > Subject: [msp430] time.h question > > > > > > Hi all, > > > > > > > > Can anyone tell me why time.h states that we have 62 seconds in a > > minute? > > > > > > > > typedef struct tm > > > > { > > > > int tm_sec; // Seconds after the minute (0,61) > > > > int tm_min; // Minutes after the hour (0,59) > > > > int tm_hour; // hours since midnight (0,23) > > > > int tm_mday; // day of the month (1,31) > > > > int tm_mon; // moths since January (0,11) > > > > int tm_year; // years since 1900 > > > > int tm_wday; // days since Sunday (0,6) > > > > int tm_yday; // days since January 1 (0,365) > > > > int tm_isdst; // Daylight saving time flag 1= active 0= not active > > > > }; > > > > > > > > And how should this be implemented? > > > > Currently I thought like this: > > > > void rtcService(void) __interrupt[TIMERA0_VECTOR] > > > > { > > > > // check for overflows > > > > if(++RtcTime.tm_sec > 61) // Seconds > > after the minute > > (0,61) > > > > { > > > > RtcTime.tm_sec = 0; > > > > if(++RtcTime.tm_min > 59) // Minutes > > after the hour > > (0,59) > > > > { > > > > RtcTime.tm_min = 0; > > > > if(++RtcTime.tm_hour > 23) // Hours since > > midnight (0,23) > > > > { > > > > if(++RtcTime.tm_wday > 6) RtcTime.tm_wday = 0; // > Days since > > Sunday (0,6) > > > > if(++RtcTime.tm_yday > 365) RtcTime.tm_yday = 0; // > days since > > january 1 (0, 365) > > > > if(++RtcTime.tm_mday > > > MonthDayTable[RtcTime.tm_mon-1]) // Day of the month (1,31) > > > > { > > > > RtcTime.tm_mday = 1; > > > > if(++RtcTime.tm_mon > 11) // months > since Januari > > (0,11) > > > > { > > > > RtcTime.tm_mon = 0; > > > > RtcTime.tm_year++; // Years since 1900 > > > > } > > > > } > > > > } > > > > } > > > > } > > > > }// (jump back into the program) > > > > > > > > But obviously this goes wrong. The thing is I need a unix > like timer > > routine for calculations > > > > And I thought that time.c would be available on the web but > so far no > > luck. > > If then I could check this and find out what/why im thinking wrong > > > > > > > > thanks martijn > > > > > > > > > > > > > > > > > > > > ------------------------ Yahoo! Groups Sponsor > > --------------------~--> > > $9.95 domain names from Yahoo!. Register anything. > > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/CFFolB/TM > > -------------------------- > > ------~-> > > > > . > > > > > > > Terms of Service. > > > > > > > > ------------------------ Yahoo! Groups Sponsor > --------------------~--> > $9.95 domain names from Yahoo!. Register anything. > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/CFFolB/TM > -------------------------- > ------~-> > > . > > > Yahoo! Groups Links > > > > > > > > >
Reply by ●November 13, 20042004-11-13
Paul thanks, Here's what i wan't to do: Get time_1 T every stime I need it, roundup to minutes MD5 hash it with some code Delete some position in th MD5 string And finally display the result on a 6 digit display. But just to have my library working completely I'd like to implement the time.h functions like Difftime, asctime. But as mentioned mainly to have it working. _____ From: Paul Curtis [mailto:plc@plc@...] Sent: zaterdag 13 november 2004 14:40 To: msp430@msp4... Subject: RE: [msp430] time.h question Martijn, Unless you *need* to use leap seconds, you can ignore them--60 seconds to a minute, usually. Most people can go through their entire lifetime without every worrying about leap seconds. I don't have my copy of the SCDTL book handy, but I'm pretty sure it details leap seconds. -- Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors > -----Original Message----- > From: Martijn Broens [mailto:martijnbroens@mart...] > Sent: 13 November 2004 13:36 > To: msp430@msp4... > Subject: RE: [msp430] time.h question > > > Hi Paul, > > > > Thanks for the reply i'm checking it > > > > _____ > > From: Paul Curtis [mailto:plc@plc@...] > Sent: zaterdag 13 november 2004 14:26 > To: msp430@msp4... > Subject: RE: [msp430] time.h question > > > > Hi Martijn, > > Try Googling for "leap seconds". I've needed to use leap > seconds for contracts where broadcasters get very uptight > about time issues. > > This is a good reference: > > http://tycho.usno.navy.mil/leapsec.html > > For those of you interested in time, the Standard C Date/Time > Library book is interesting, but has bugs. > > http://www.amazon.com/exec/obidos/tg/detail/-/0879304960/102-5 > 642561-486 > 1761?v=glance > > -- > Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk > CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors > > > -----Original Message----- > > From: martijnbroens@mart... [mailto:martijnbroens@mart...] > > Sent: 13 November 2004 12:58 > > To: msp430@msp4... > > Subject: [msp430] time.h question > > > > > > Hi all, > > > > > > > > Can anyone tell me why time.h states that we have 62 seconds in a > > minute? > > > > > > > > typedef struct tm > > > > { > > > > int tm_sec; // Seconds after the minute (0,61) > > > > int tm_min; // Minutes after the hour (0,59) > > > > int tm_hour; // hours since midnight (0,23) > > > > int tm_mday; // day of the month (1,31) > > > > int tm_mon; // moths since January (0,11) > > > > int tm_year; // years since 1900 > > > > int tm_wday; // days since Sunday (0,6) > > > > int tm_yday; // days since January 1 (0,365) > > > > int tm_isdst; // Daylight saving time flag 1= active 0= not active > > > > }; > > > > > > > > And how should this be implemented? > > > > Currently I thought like this: > > > > void rtcService(void) __interrupt[TIMERA0_VECTOR] > > > > { > > > > // check for overflows > > > > if(++RtcTime.tm_sec > 61) // Seconds > > after the minute > > (0,61) > > > > { > > > > RtcTime.tm_sec = 0; > > > > if(++RtcTime.tm_min > 59) // Minutes > > after the hour > > (0,59) > > > > { > > > > RtcTime.tm_min = 0; > > > > if(++RtcTime.tm_hour > 23) // Hours since > > midnight (0,23) > > > > { > > > > if(++RtcTime.tm_wday > 6) RtcTime.tm_wday = 0; // > Days since > > Sunday (0,6) > > > > if(++RtcTime.tm_yday > 365) RtcTime.tm_yday = 0; // > days since > > january 1 (0, 365) > > > > if(++RtcTime.tm_mday > > > MonthDayTable[RtcTime.tm_mon-1]) // Day of the month (1,31) > > > > { > > > > RtcTime.tm_mday = 1; > > > > if(++RtcTime.tm_mon > 11) // months > since Januari > > (0,11) > > > > { > > > > RtcTime.tm_mon = 0; > > > > RtcTime.tm_year++; // Years since 1900 > > > > } > > > > } > > > > } > > > > } > > > > } > > > > }// (jump back into the program) > > > > > > > > But obviously this goes wrong. The thing is I need a unix > like timer > > routine for calculations > > > > And I thought that time.c would be available on the web but > so far no > > luck. > > If then I could check this and find out what/why im thinking wrong > > > > > > > > thanks martijn > > > > > > > > > > > > > > > > > > > > ------------------------ Yahoo! Groups Sponsor > > --------------------~--> > > $9.95 domain names from Yahoo!. Register anything. > > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/CFFolB/TM > > -------------------------- > > ------~-> > > > > . > > > > > > > Terms of Service. > > > > > > > > ------------------------ Yahoo! Groups Sponsor > --------------------~--> > $9.95 domain names from Yahoo!. Register anything. > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/CFFolB/TM > -------------------------- > ------~-> > > . > > > > Terms of Service.