/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int main()
{
    time_t tim;
    struct tm *timbuf;
    char timstr[33];
    tim = time(NULL);
    timbuf = localtime(&tim);
    strftime(timstr, sizeof(timstr), "%Y-%m-%dT%H:%M:%S.000", timbuf);
    sprintf(timstr+strlen(timstr), "%c%02d:%02d", timbuf->tm_gmtoff > 0 ? '+' : '-', abs(timbuf->tm_gmtoff) / 3600, (abs(timbuf->tm_gmtoff) / 60) % 60);
    printf("%s\n", timstr);
    return 0;
}
