Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

libc Timezone Testing

Name: Anonymous 2012-10-12 16:52

Hey /prog/,
Making a program dealing with RFC2822 dates. Can you guys compile & run the following and advise if it's the correct timezone.
You time is much appreciated.

#ifdef _WIN32
#define    __MSVCRT_VERSION__    0x0601
#include <windows.h>
#endif
#include <time.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    #ifndef _WIN32
    time_t RawTime;
    #else
    __time64_t RawTime;
    #endif
    struct tm GMT, Local, *TimeInfo;

    const char *Days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
    const char *Months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

    RawTime =
    #ifndef _WIN32
        time(NULL);
    #else
        _time64(NULL);
    #endif
    if (RawTime == -1)
        return 1;

    TimeInfo =
    #ifndef _WIN32
        gmtime(&RawTime);
    #else
        (struct tm *)_gmtime64(&RawTime);
    #endif
    GMT = *TimeInfo;

    TimeInfo =
    #ifndef _WIN32
        localtime(&RawTime);
    #else
        (struct tm *)_localtime64(&RawTime);
    #endif
    Local = *TimeInfo;

    if (Local.tm_hour > 12)
        GMT.tm_hour += 24;
    if (Local.tm_isdst > 0)
        GMT.tm_hour += 2;

    printf("%s, %.2d %s %d %.2d:%.2d:%.2d %+03i00",
        Days[Local.tm_wday], Local.tm_mday, Months[Local.tm_mon], Local.tm_year + 1900,
        Local.tm_hour, Local.tm_min, Local.tm_sec,
        GMT.tm_hour - Local.tm_hour);

    return 0;
}

Name: Anonymous 2012-10-12 16:56

East Cost here, it works fine.

Name: Anonymous 2012-10-12 16:56

>>2
*Coast

Name: did not see _WIN32 2012-10-12 17:04

#include <windows.h>
I died there.

Name: Anonymous 2012-10-12 17:04

Works OK here at UTC+2.

Name: Anonymous 2012-10-13 14:41

It's correct here for me on Pacific Time (currently UTC-7)

Name: Anonymous 2012-10-14 20:03

UTF-8

Name: Anonymous 2012-10-14 20:16

fuck off, freedom-hating cocksucker

Don't change these.
Name: Email:
Entire Thread Thread List