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

julian routin conversion

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



Joined: 21 Feb 2005
Posts: 1

View user's profile Send private message

julian routin conversion
PostPosted: Mon Feb 21, 2005 5:39 pm     Reply with quote

Does anybody know a place to seek a good julian-to-gregorian date convertion?
I wander if it is one to PIC.

Thanks in advance

Alejandro
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Feb 21, 2005 6:36 pm     Reply with quote

You will have to test it

Code:

/* Function JulianToGregorian. Takes 4 arguments: Julian day number,  */
/* and dd, mm, and yyyy for a Gregorian date. Function calculates     */
/* Gregorian date corresponding to JDN and stores it in dd, mm, yyyy  */
/* Note: this function makes use of a widely-published algorithm.     */
/* Unfortunately, it seems to have been optimsed for efficiency       */
/* rather than for comprehensibility. There's a lesson here:          */
/*      if you don't need to understand something, don't.             */
void JulianToGregorian (int32 jd, int16 * dd, int16 * mm, int16 * yyyy)
{
int32 temp,
     i,
     n,
     j ;

temp = jd + 68569 ;
n = (4 * temp) / 146097 ;
temp = temp - (146097 * n + 3) / 4 ;
i = (4000 * (temp + 1)) / 1461001 ;
temp = temp - (1461 * i) / 4 + 31 ;
j = (80 * temp) / 2447 ;
*dd = temp - (2447 * j) / 80 ;
temp = j / 11 ;
*mm = j + 2 - (12 * temp) ;
*yyyy = 100 * (n - 49) + i + temp ;
}
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