Ejemplo n.º 1
0
double
ymd2y(YMD ymd)
{
    double y;

    /* normalize the time */
    ymd = ymd2ymd(ymd);

    y = (double)ymdGetYear(ymd) + (ymd2dd(ymd) / y2doy(ymdGetYear(ymd)));

    return(y);
}
Ejemplo n.º 2
0
double
ymd2dd(YMD ymd)
{
    double dd;
    double j0;
    double j;

    /* normalize the time */
    ymd = ymd2ymd(ymd);

    /* get the julian day number of the target date */
    j = ymd2j(ymd);

    /* get the julian day number of the start of the year */
    j0 = gcal2j(ymdGetYear(ymd), 1, 1) - 0.5;

    dd = j - j0 + 1;

    return(dd);
}
Ejemplo n.º 3
0
char *
fmt_ymd(YMD ymd)
{
    char *p;
    double j;	/* julian day number of target time */
    int fpart;
    int ipart;
    int today;

    /* get a buffer */
    p = ymdbuf[nxtymdbuf++];
    nxtymdbuf %= NYMDBUF;

    /* normalize the time */
    ymd = ymd2ymd(ymd);

    /* get the julian day number */
    j = ymd2j(ymd);

    /* get the day of the week */
    today = j2dow(j);

    ipart = (int)ymdGetSeconds(ymd);
    fpart = 1e3 * (ymdGetSeconds(ymd) - ipart);

    (void)sprintf(p, "%3.3s %3.3s %2d %02d:%02d:%02d.%03d %4d",
	    dow[today],
	    moy[ymdGetMonth(ymd)-1],
	    (int)ymdGetDay(ymd),
	    (int)ymdGetHours(ymd),
	    (int)ymdGetMinutes(ymd),
	    ipart, fpart,
	    ((ymdGetYear(ymd) > 0) ? ymdGetYear(ymd) : (1-ymdGetYear(ymd))));

    if (ymdGetYear(ymd) <= 0) {
	(void)strcat(p, " BC");
    }

    return(p);
}