View previous topic :: View next topic |
Author |
Message |
crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
time and date routines |
Posted: Wed Nov 28, 2007 7:49 am |
|
|
Hi there.
Does any one perhaps have any useful date and time routines lying around somewhere. I am particularly looking for routines to convert a "seconds since date" to a D/M/Y H:M:S format and vice versa.
I want to use it with a RTC iButton DS1904. I have searched the forum/code lib and found some routines by Van Hauser (don't think its correct spelling) but it is not exactly what i had in mind. A long time ago i had some routines which i think is right but can't find them anymore, and don't know if it was from this forum either.
Can anybody please help?
Kind regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
time and date routines |
Posted: Wed Nov 28, 2007 11:48 pm |
|
|
Hi, thanx PCM Programmer i've just downloaded the app note, funny when i searched for RTC on maxim site yesterday i did not get (... or see...) this note even though it has RTC as one of its keywords... Anyway, it does seem like they have everything in there, but the code will roll over in 2038, by that time i will be quite old, and hopefully not working anymore... but would it be possible to change this date? i haven't read to code in depth yet so i'm asking you as professional.
I also did some homework of my own and found this:
http://www.picbasic.co.uk/forum/showthread.php?s=&threadid=250&perpage=15&pagenumber=1
it is everything i need in the wrong language, PBP. I started converting it to C but not being familiar with some of the functions, nor having a reference manual for that compiler it is going rather slow. Any translators willing to do the honor? or point me in the right direction?
Kind regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 29, 2007 12:46 am |
|
|
Quote: | so i'm asking you as professional. |
I am still here at the company, working here at 10:40pm on a company
project. I'm not sure when I get to go home. I can't work on your
problem at the moment. |
|
|
crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
time and date routines |
Posted: Thu Nov 29, 2007 5:15 am |
|
|
No prob, i understand we all have to work to stay alive...
I will try and find a PBP manual and have a look at the app note and see what i can cook up with that. Thanx for the effort so far
Kind Regards |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Nov 29, 2007 8:45 am |
|
|
Quote: | but the code will roll over in 2038 | A signed 32 bit integer as used in UNIX will roll over in 2038, but here the Maxim app note is using unsigned variables everywhere. A 32 bit unsigned counter would last 136 years and roll over in 2106. Who is wrong, me or Maxim?
It is not to difficult to change the Maxim app note to start counting in the year 2000, winning you another 30 years and simplifying the code as well.
Please note that in the Maxim application all unsigned longs are 32 bit integers, not 16 bit as in the CCS compiler. |
|
|
crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
|
Posted: Thu Nov 29, 2007 9:26 am |
|
|
Hi Ckielstra i think your right about the 136 year thing, that figure does sound very familiar. Thanx for pointing out the difference in the long interpretation.
I will see if i have energy tonight to start digesting information and writing some code...
Kind Regards |
|
|
|