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 support@ccsinfo.com

Unix time

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



Joined: 17 Jan 2005
Posts: 8

View user's profile Send private message Send e-mail

Unix time
PostPosted: Tue Jan 13, 2009 11:09 am     Reply with quote

Does CCS have any built-in functions to convert a gps dato to Unix time?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 13, 2009 1:11 pm     Reply with quote

Use the forum search engine:
http://www.ccsinfo.com/forum/search.php
Search for:
Quote:
unix time

Set it to:
Quote:
Search for all terms
mabd



Joined: 17 Jan 2005
Posts: 8

View user's profile Send private message Send e-mail

Unix time
PostPosted: Wed Jan 14, 2009 1:46 am     Reply with quote

When I search this topic appear this messsage:

No topics or posts met your search criteria

It's necessary to Search for any terms or use query as entered

http://www.ccsinfo.com/forum/viewtopic.php?t=36475&highlight=unix

In this topic he wants to convert a unix time stamp to something usable. I want to do otherwise -> convert a gps date to unix time stamp. I haven't found any function that do this.

Is there any function that do this?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 14, 2009 1:59 am     Reply with quote

The search worked for me. I found 28 matches.
But anyway, post the format of the "gps date". Post an example of it.
mabd



Joined: 17 Jan 2005
Posts: 8

View user's profile Send private message Send e-mail

unix time
PostPosted: Wed Jan 14, 2009 4:29 am     Reply with quote

Gps date:

In the GPRMC Gps NMEA sentence we have the date:

6 characters: 131009 (day/month/year)

And in the GPGGA we have the hour:

6 characters: 110515 (hour/minute/second)

Then I create an struct_tm fecha with this members:

fecha.tm_sec=15
fecha.tm_min=5
fecha.tm_hour=11
fecha.tm_mday=13
fecha.tm_mon=1
fecha.tm_year=2009

I think that the function to convert this date to unixtime is mktime(struct_tm * timeT) in rtctimer.c

Please could you send me an example?.

Thanks
Ttelmah
Guest







PostPosted: Wed Jan 14, 2009 8:44 am     Reply with quote

The 'odds' are that few people will be using Unix time 'locally' in any CCS application.
However the arithmetic is pretty basic. Do a search on the USNO site, for 'Julian date formula'. This gives a formula that returns a Julian day number using basic integer arithmetic, from a given Gregorian month/day/year, with the correct allowances for leap years etc..
Now Unix times, are simply a count in seconds from Jan 1st 1970, with a few assumptions (that can lead to 'oddities', especially when going the other way). The primary one is 86400 seconds per day.
If you calculate the Julian day number, then subtract the one (precalculate this) for the Unix start time, multiply the result by 86400, then add the seconds, minutes*60, and hours*3600 (remember to ensure that you cast all integers 'up' to int32 before performing the arithmetic), you get the Unix time.
You should be able to generate the value in about 10 minutes work.

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