All pastes #491012 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-16 11:30 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>

int
main ()
{
  struct tm tm, *tx;
  time_t start;
  char *buf1 = "2007-05-16 13:20:00 +0200";
  char buf2[128];

  memset (&tm, 0, sizeof (struct tm));
  strptime (buf1, "%Y-%m-%d %H:%M:%S %z", &tm);
  start = mktime (&tm);
  tx = localtime(&start);
  strftime (buf2, sizeof buf2, "%Y-%m-%d %H:%M:%S %z", tx);
  printf ("%s\n", buf1);
  printf ("%s\n", buf2);
}


[root@orbit-14 /root]$ /mnt/lithium/jrydberg/p3
2007-05-16 13:20:00 +0200
2007-05-16 14:20:00 +0200