chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] srfi-19 doesn't work with stable Chicken release


From: Dan Muresan
Subject: Re: [Chicken-users] srfi-19 doesn't work with stable Chicken release
Date: Sun, 20 May 2007 04:14:54 +0300
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070221 SeaMonkey/1.1.1

Chicken 2.6 has inconsistent meaning for timezone offset across platforms. 2.61 fixed this.

Provided you are not using MacOS X or Windows you can get the current version (2.6.9) which skips the requirement otherwise.

Well, I was in a rush, so I've wrapped strftime(). This might actually be useful to others, so I'm posting it. I've used SWIG, but I'm sure it's trivial using the Chicken FFI (which I don't know though):

#include <time.h>
#include <stdlib.h>
#include <string.h>

// See strftime(3) manpage for format string
char *system_time (const char *fmt) {
  time_t t;
  struct tm tm;

  time (& t);
  localtime_r (& t, & tm);
  char buf [500];
  size_t ret = strftime (buf, sizeof (buf), fmt, & tm);
  if (ret == 0) return NULL;
  else {
    char *res = malloc (ret + 1);
    memcpy (res, buf, ret + 1);
    return res;
  }
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]