CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Converting a unix time stamp

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ktallevi



Joined: 17 Dec 2005
Posts: 58

View user's profile Send private message

Converting a unix time stamp
PostPosted: Tue Oct 21, 2008 12:49 pm     Reply with quote

Does CCS have any built-in functions to convert a unix time stamp to something usable.

Eg. 685586AC (hex) -> 16:05:00 June 20 2025

thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 21, 2008 4:09 pm     Reply with quote

The ctime() function does the conversion from a Unix Timestamp to
a readable date and time. That function is the rtctimer.c file, which
is included with the CCS compiler. Here is the file location:
Quote:
c:\Program Files\picc\Drivers\rtctimer.c


The test program shown below has the following output:
Quote:
Fri Jun 20 16:05:00 2025

Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include <rtctimer.c>

//====================================
void main()
{
int32 tTime;
int8 tString[80];

tTime = 0x685586AC;
 
ctime(&tTime, tString);

printf(tString);


while(1);
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Oct 21, 2008 4:25 pm     Reply with quote

Not for UNIX date/time, but in the Code Library are some optimized time routines for years 2001 - 2098.
http://www.ccsinfo.com/forum/viewtopic.php?t=25611
Add or subtract the number of seconds from 1-1-1970 to 1-1-2001 and you are up and running.
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

PostPosted: Wed Oct 22, 2008 12:28 am     Reply with quote

Or have a look at the AN517 appnote from Maxim/Dallas.
D-Kens



Joined: 09 May 2005
Posts: 35
Location: Toulouse (France)

View user's profile Send private message MSN Messenger

PostPosted: Mon Jun 08, 2009 3:45 am     Reply with quote

PCM programmer wrote:
The ctime() function does the conversion from a Unix Timestamp to a readable date and time. That function is the rtctimer.c file, which is included with the CCS compiler.

Nice !!! I didn't know there were tools to work with Unix timestamps... But... Euh... How comes I don't have the RTCTimer library in my Drivers directory ? Confused
Ttelmah
Guest







PostPosted: Mon Jun 08, 2009 5:06 am     Reply with quote

How old is your compiler?.
This library, only appeared with the V4 releases. It came out, mid 2007.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group