Пример #1
0
int main(int argc, char *argv[])
{
  time_t t;
  struct tm ttm;
  char buf[256];

  fprintf(stderr, "Starting...\n");
  fprintf(stderr, "TZ is %s\n", getenv("TZ"));
  fprintf(stderr, "TZ Offset is %ld\n", timezone);

  memset(&ttm, 0, sizeof(struct tm));
  t = 996887354;
  fprintf(stderr, "US/Eastern Test\n");
  neo_time_expand(t, "US/Eastern", &ttm);

  fprintf(stderr, "TZ is %s\n", getenv("TZ"));
  fprintf(stderr, "TZ Offset is %ld\n", timezone);
  fprintf(stderr, "TZ Offset is %ld\n", neo_tz_offset(&ttm));
  fprintf(stderr, "From tm: %s %ld\n", ttm.tm_zone, ttm.tm_gmtoff);
  strftime(buf, sizeof(buf), "%Y/%m/%d %H:%M:%S", &ttm);
  fprintf(stderr, "Time is %s\n", buf);

  fprintf(stderr, "GMT Test\n");
  neo_time_expand(t, "GMT", &ttm);

  fprintf(stderr, "TZ is %s\n", getenv("TZ"));
  fprintf(stderr, "TZ Offset is %ld\n", timezone);
  fprintf(stderr, "TZ Offset is %ld\n", neo_tz_offset(&ttm));
  fprintf(stderr, "From tm: %s %ld\n", ttm.tm_zone, ttm.tm_gmtoff);
  strftime(buf, sizeof(buf), "%Y/%m/%d %H:%M:%S", &ttm);
  fprintf(stderr, "Time is %s\n", buf);

  return 0;
}
Пример #2
0
/* This returns the expanded version in the standard python time tuple
 * */
static PyObject * p_time_expand (PyObject *self, PyObject *args)
{
  PyObject *rv;
  int tt;
  struct tm ttm;
  char *tz;

  if (!PyArg_ParseTuple(args, "is:time_expand(time_t, timezone string)", &tt, &tz))
    return NULL;

  neo_time_expand(tt, tz, &ttm); 

  rv = Py_BuildValue("(i,i,i,i,i,i,i,i,i)", ttm.tm_year + 1900, ttm.tm_mon + 1, 
      ttm.tm_mday, ttm.tm_hour, ttm.tm_min, ttm.tm_sec, ttm.tm_wday, 0, ttm.tm_isdst);
  return rv;
}