[ create a new paste ] login | about

Link: http://codepad.org/KTZwUHt0    [ raw code | output | fork ]

pmg - C, pasted on Nov 5:
#include <limits.h>
#include <stdio.h>
#include <time.h>

int main(void) {
  struct tm test = {0};

  test.tm_mon = 1;
  test.tm_sec = 90;
  test.tm_year = 200;

  printf("time_t is %d bits long.\n", CHAR_BIT * (int)sizeof (time_t));
  if (mktime(&test) == (time_t)-1) {
    printf("error normalizing\n");
  } else {
    printf("normalized to %d-%02d-%02d T %02d:%02d:%02d\n",
          test.tm_year + 1900,
          test.tm_mon + 1,
          test.tm_mday,
          test.tm_hour,
          test.tm_min,
          test.tm_sec);
  }

  return 0;
}


Output:
1
2
time_t is 32 bits long.
error normalizing


Create a new paste based on this one


Comments: