xffm translation: date specification
Benedikt Meurer
Benedikt.Meurer at unix-ag.uni-siegen.de
Thu Jun 19 16:48:30 CEST 2003
On Thu, 19, Jun 2003, Bernhard Walle wrote:
> > > Why? (IMHO) we try to keep the other components "hack-free" (we had
> > > discussion on wm and panel lately), so lets keep xffm "hack-free"
> > > as well (just my opinion).
> >
> > The only issue here is that since I have no idea what the hack consists
> > of (having just done a cut and paste from the GNU-ls code) I would
> > probably just replace on hack with another. If you know how to get rid
> > of the hack, please do. All I ask for is:
> > -files younger than 6 months show hh:mm instead of year
> > -no strings for month translations be necessary in the po files (they're
> > big enough already).
> >
> > If you could help me on these issues I would greatly appreciate it.
>
>
> Where's the problem? Something like
>
>
> char *getModificationString (const char* path) {
> static char string[BUFSIZ];
> time_t now = time(NULL);
> struct stat statstruct;
> char* formatstring;
>
> memset (string, 0, BUFSIZ);
>
> if (stat (path, &statstruct) != 0) {
> return NULL;
> }
>
> formatstring = difftime(now, statstruct.st_mtime) > 24*60*60*30*6
> ? OLD_FORMATSTRING
> : NEW_FORMATSTRING;
>
>
> if (strftime(string, BUFSIZ, formatstring, localtime(&statstruct.st_mtime)) == 0) {
> return NULL;
> }
>
> return string;
> }
>
> would work, just the two strings must be translated.
I tend to agree with Bernhard, although I think, it would be helpful
to use GLib "Date/Time" functions instead. See
http://developer.gnome.org/doc/API/2.0/glib/glib-Date-and-Time-Functions.html
Just for portability reasons. You should use g_date_days_between() instead
of difftime and g_date_strftime() instead of strftime. Just my 2 euro.
And one note on localtime(): Use localtime_r() whenever possible, since
xffm may use threads in the future, and mistakes related to localtime()
usage with threads are hard to track. configure already checks for
localtime_r().
> Gruss,
> Bernhard
Benedikt
--
NetBSD Operating system: http://www.NetBSD.org/
pkgsrc "Work in progress": http://pkgsrc-wip.sf.net/
XFce desktop environment: http://www.xfce.org/
German Unix-AG Association: http://www.unix-ag.org/
More information about the Xfce4-dev
mailing list