Astro-Nova

 view release on metacpan or  search on metacpan

libnova-0.15.0/ChangeLog  view on Meta::CPAN

	Fix supplied by Danie Malan

20030103
	- src/transform.c in get_hrz_from_equ ()

	Algorithm changed to one, which use atan2 instead of atan function
	and thus returns 0..2PI for Azimuth instead of -pi/2..pi/2

	- src/julian_day.c in get_julian_day ()
	
	Correct check for 4th October 1582 (Julian/Gregorian calendar)

	Petr Kubanek <petr@lascaux.asu.cas.cz>

20022911 - src/julian_day.c in get_timet_from_julian ()
	
	Spurious errors were caused by loctime.tm_isdst not
	being initialised to 0.  
	
	Fix supplied by Petr Kubanek <petr@lascaux.asu.cas.cz>

libnova-0.15.0/src/julian_day.c  view on Meta::CPAN


/* Standard Win32 apps do not have POSIX support. */
#ifndef __WIN32__
#include <sys/time.h>
#endif

/*! \fn double ln_get_julian_day (struct ln_date * date)
* \param date Date required.
* \return Julian day
*
* Calculate the julian day from a calendar day. 
* Valid for positive and negative years but not for negative JD.
*/
/* Formula 7.1 on pg 61 
*/
double ln_get_julian_day (struct ln_date * date)
{
    double JD;
    double days;
    int a,b;
    struct ln_date local_date;

libnova-0.15.0/src/julian_day.c  view on Meta::CPAN

    memcpy (&local_date, date, sizeof (struct ln_date));
		
    /* check for month = January or February */
    if (local_date.months < 3 ) {
        local_date.years--;
	    local_date.months += 12;
	}
	
	a = local_date.years / 100;
	
	/* check for Julian or Gregorian calendar (starts Oct 4th 1582) */
	if (local_date.years > 1582 || 
		(local_date.years == 1582 && 
		(local_date.months > 10 || 
		(local_date.months == 10 && local_date.days >= 4)))) {
	    /* Gregorian calendar */    
	    b = 2 - a + (a / 4);
	} else {
	    /* Julian calendar */
	    b = 0;
	}
	
	/* add a fraction of hours, minutes and secs to days*/
	days = local_date.days + (double)(local_date.hours / 24.0) + (double)(local_date.minutes / 1440.0) + (double)(local_date.seconds /  86400.0);

	/* now get the JD */
	JD = (int)(365.25 * (local_date.years + 4716)) + 
	    (int)(30.6001 * (local_date.months + 1)) + days + b - 1524.5;
	

libnova-0.15.0/src/julian_day.c  view on Meta::CPAN

    /* get julian day */
    JD = ln_get_julian_day (date);
    JD += 1.5;
    day = (int)JD % 7; 
    
    return day;
}	

/*! \fn void ln_get_date (double JD, struct ln_date * date)
* \param JD Julian day
* \param date Pointer to new calendar date.
*
* Calculate the date from the Julian day  
*/
void ln_get_date (double JD, struct ln_date * date)
{
   int A,a,B,C,D,E;
   double F,Z;
   
   JD += 0.5;
   Z = (int) JD;

libnova-0.15.0/src/julian_day.c  view on Meta::CPAN

   
   /* get the year */
   if (date->months > 2)
       date->years = C - 4716;
   else
       date->years = C - 4715;
}	

/*! \fn void ln_get_date_from_timet (time_t * t, struct ln_date * date)
* \param t system time
* \param date Pointer to new calendar date.
*
* Set date from system time
*/
void ln_get_date_from_timet (time_t * t, struct ln_date * date)
{
	struct tm gmt;

	/* convert to UTC time representation */
	gmtime_r (t, &gmt);
    	
	ln_get_date_from_tm (&gmt, date);
}

/*! \fn void ln_get_date_from_tm (struct tm * t, struct ln_date * date)
* \param tm system tm structure
* \param date Pointer to new calendar date.
*
* Set date from system tm structure
*/
void ln_get_date_from_tm (struct tm * t, struct ln_date * date)
{
	/* fill in date struct */
	date->seconds = t->tm_sec;
	date->minutes = t->tm_min;
	date->hours = t->tm_hour;
	date->days = t->tm_mday;

libnova-0.15.0/src/julian_day.c  view on Meta::CPAN

{
	struct ln_date date;
	
	ln_zonedate_to_date (zonedate, &date);

	return ln_get_julian_day (&date);
}

/*! \fn void ln_get_local_date (double JD, struct ln_zonedate * zonedate)
* \param JD Julian day
* \param zonedate Pointer to new calendar date.
*
* Calculate the zone date from the Julian day (UT). Gets zone info from 
* system using either _timezone or tm_gmtoff fields.
*/
void ln_get_local_date (double JD, struct ln_zonedate * zonedate)
{
	struct ln_date date;
	time_t curtime;
	struct tm *loctime;
	long gmtoff;

libnova-0.15.0/src/julian_day.c  view on Meta::CPAN

 	curtime = time (NULL);
 	loctime = localtime(&curtime);
 	gmtoff = loctime->tm_gmtoff;
	// otherwise there is no reasonable way how to get that:(
	// tm_gmtoff already included DST
#endif
	ln_date_to_zonedate (&date, zonedate, gmtoff);
}

/*! \fn int ln_get_date_from_mpc (struct ln_date* date, char* mpc_date)
* \param date Pointer to new calendar date.
* \param mpc_date Pointer to string MPC date
* \return 0 for valid date
*
* Calculate the local date from the a MPC packed date.
* See http://cfa-www.harvard.edu/iau/info/PackedDates.html for info.
*/
int ln_get_date_from_mpc (struct ln_date* date, char* mpc_date)
{
	char year[3];
	char month[2];

libnova-0.15.0/src/libnova/julian_day.h  view on Meta::CPAN

#define __WIN32__
#endif

#include <time.h>
#include <libnova/ln_types.h>

#ifdef __cplusplus
extern "C" {
#endif

/*! \defgroup calendar General Calendar Functions 
*/
 
/*! \fn double ln_get_julian_day (struct ln_date * date)
* \ingroup calendar
* \brief Calculate the julian day from date.
*/
double LIBNOVA_EXPORT ln_get_julian_day (struct ln_date * date);

/*! \fn void ln_get_date (double JD, struct ln_date * date)
* \ingroup calendar
* \brief Calculate the date from the julian day.
*/
void LIBNOVA_EXPORT ln_get_date (double JD, struct ln_date * date);

/*! \fn void ln_get_date_from_timet (time_t * t, struct ln_date * date)
* \\ingroup calendar
* \brief Set date from system time
*/
void LIBNOVA_EXPORT ln_get_date_from_timet (time_t * t, struct ln_date * date);

/*! \fn void ln_get_date_from_tm (struct tm * t, struct ln_date * date)
* \\ingroup calendar
* \brief Set date from system tm structure
*/
void LIBNOVA_EXPORT ln_get_date_from_tm (struct tm * t, struct ln_date * date);

/*! \fn void ln_get_local_date (double JD, struct ln_zonedate * zonedate)
* \ingroup calender
* \brief Calculate the zone date from the Julian day  
*/
void LIBNOVA_EXPORT ln_get_local_date (double JD, struct ln_zonedate * zonedate);

/*! \fn unsigned int ln_get_day_of_week (struct ln_date * date)
* \ingroup calendar
* \brief Calculate day of the week.
*/
unsigned int LIBNOVA_EXPORT ln_get_day_of_week (struct ln_date *date);
	
/*! \fn double ln_get_julian_from_sys ()
* \brief Calculate julian day from system time.
* \ingroup calendar
*/
double LIBNOVA_EXPORT ln_get_julian_from_sys ();


/*! \fn void ln_get_date_from_sys (struct ln_date * date)
* \brief Calculate date from system date
* \ingroup calendar
*/
void LIBNOVA_EXPORT ln_get_date_from_sys (struct ln_date * date);
	
/*! \fn double ln_get_julian_from_timet (time_t * time)
* \brief Calculate julian day from time_t
* \ingroup calendar
*/
double LIBNOVA_EXPORT ln_get_julian_from_timet (time_t * in_time);

/*! \fn void ln_get_timet_from_julian (double JD, time_t * in_time)
* \brief Calculate time_t from julian day
* \ingroup calendar
*/
void LIBNOVA_EXPORT ln_get_timet_from_julian (double JD, time_t * in_time);

/*! \fn double ln_get_julian_local_date(struct ln_zonedate* zonedate)
* \brief Calculate Julian day from local date
* \ingroup calendar
*/
double LIBNOVA_EXPORT ln_get_julian_local_date(struct ln_zonedate* zonedate);
	
/*! \fn int ln_get_date_from_mpc (struct ln_date* date, char* mpc_date)
* \brief Calculate the local date from the a MPC packed date.
* \ingroup calendar
*/
int LIBNOVA_EXPORT ln_get_date_from_mpc (struct ln_date* date, char* mpc_date);
	
/*! \fn double ln_get_julian_from_mpc (char* mpc_date)
* \brief Calculate the julian day from the a MPC packed date.
* \ingroup calendar
*/
double LIBNOVA_EXPORT ln_get_julian_from_mpc (char* mpc_date);

/*! \fn void ln_date_to_zonedate (struct ln_date * date, struct ln_zonedate * zonedate, long gmtoff)
* \brief convert ln_date to ln_zonedate, zero zone info
* \ingroup conversion
*/
void LIBNOVA_EXPORT ln_date_to_zonedate (struct ln_date * date, struct ln_zonedate * zonedate, long gmtoff);

/*! \fn void ln_zonedate_to_date (struct ln_zonedate * zonedate, struct ln_date * date)



( run in 0.469 second using v1.01-cache-2.11-cpan-c333fce770f )