#include "nist.h"

void set_time()
{
    struct timeval
        tv;

    gettimeofday(&tv, NULL);                /* settings from the local time  */
    local = *localtime(&tv.tv_sec);         /* convert to broken-down parts */

    local.tm_sec    = ss;                   /* set the requested time       */
    local.tm_min    = mm;
    local.tm_hour   = hh;
    local.tm_mday   = dd;
    local.tm_mon    = mo - 1;
    local.tm_year   = yy;

    if (!quiet)
        printf("New time: %s", asctime(&local));

    if (time_update)                        /* update the time if requested */
    {
        tv.tv_sec = mktime(&local);         /* total # secs from 'local'    */
        tv.tv_usec = 250000;                /* 1/4 of the second, assuming  */
                                            /* it's rounded up byond 1/2 secc*/
        if (settimeofday(&tv, NULL))        /* alter the time               */
            error("Can't set the time");
    }
}
