#include "nist.h"

char
    *state[] =
    {
        "",
        "OK. time ok again within 10'",
        "OK. time is off by more than 5\"",
        "U/S"
    };

int nistserver(char *cmd)
{
    char
        *cp;
    unsigned
        julian,
        dst,
        ls,
        h;

    if
    (
        sscanf
        (
            cmd,
            "%u %u-%u-%u %u:%u:%u %u %u %u"
            , &julian
            , &yy
            , &mo
            , &dd
            , &hh
            , &mm
            , &ss
            , &dst
            , &ls
            , &h
        ) != 10
    )
        return (0);                         /* this line wasn't the time */

    if (h)
        printf("The server is %s.\n", state[h]);

    if ((cp = strchr(cmd, '*')))            /* term. the timestring nicely */
        strcpy(cp + 1, "\n");

    if (yy < 90)                            /* Century: 2003 as 03, becomes */
        yy += 10;                           /* 13: 13 years past 1990       */

    return (h == 0);                        /* timeline found if server is ok */
}

            
