All pastes #392893 Raw Edit

Something

public text v1 · immutable
·published 2007-03-13 04:25 UTC
rendered paste body
#define _XOPEN_SOURCE
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <utime.h>

main()
{
        time_t currenttime;
        time_t start;
        time_t stop;

        currenttime = time(&currenttime);

        struct tm comparetime;
        struct tm starttime;
        struct tm stoptime;

        char starttime_input[64] = "10:49";
        char stoptime_input[64] = "20:49";

        localtime_r(&currenttime, &comparetime);
        localtime_r(&currenttime, &starttime);
        localtime_r(&currenttime, &stoptime);
        strptime(&starttime_input, "%H:%M", &starttime);
        strptime(&stoptime_input, "%H:%M", &stoptime);

        start = mktime(&starttime);
        stop = mktime(&stoptime);

        printf("current time is: %i\n", currenttime);
        printf("start time is: %i\n", start);
        printf("stop time is: %i\n", stop);
}