delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/12/26/18:37:04

From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Cc: djgpp AT delorie DOT com
Subject: Re: strftime: Need Help with Time Offsets
Date: Tue, 26 Dec 2000 23:36:06 +0000
Message-ID: <2fai4t4koosl9p8ml5uu4ft7o4c4gad3m1@4ax.com>
References: <0nt94tkh5ptfohe9414da1u3geja7ml4vm AT 4ax DOT com> <Pine DOT SUN DOT 3 DOT 91 DOT 1001224073918 DOT 7747A-100000 AT is>
In-Reply-To: <Pine.SUN.3.91.1001224073918.7747A-100000@is>
X-Mailer: Forte Agent 1.7/32.534
MIME-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id SAA08731
Reply-To: djgpp AT delorie DOT com

On Sun, 24 Dec 2000, Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:

> On Sat, 23 Dec 2000, Jason Green wrote:
> 
> > > But C99 defines about a dozen more conversion specifiers which aren't
> > > supported by DJGPP right now.  It would be nice to add them as well.
> > 
> > I agree, but this all takes time.  If %z is fixed now shouldn't it go
> > in?
> 
> I didn't say it shouldn't.  But fixing %z alone doesn't sound like a big 
> win to me.  

Well I started this by trying to fix one user's problem...  :-/

AFAICT, the good news is that DJGPP is not far from compliant already
(if you conveniently ignore locales).

Apart from support for locales, the missing/changed functionality
seems straight forward to implement.  The only one I really have a
problem with is calculating ISO week numbers.

>  Also, the docs needs to be amended to describe %z.

--- src/libc/ansi/time/strftime.txh.orig  Mon Aug  2 12:28:18 1999
+++ src/libc/ansi/time/strftime.txh     Sun Dec 24 11:01:52 2000
@@ -149,6 +149,10 @@

 The timezone abbreviation (@code{EDT})

+@item %z
+
+The time-zone as hour offset from UTC (@code{-0500})
+
 @item %%

 A percent symbol (@code{%})


> > BTW, if I fill a struct tm with values for 0/Jan/YYYY, then call
> > mktime(), it should be modified to 31/Dec/(YYYY-1), right?  This isn't
> > happening.
> 
> Please post a complete example.

The program below prints:

Mon, 00 Jan 2001

Unless I am mistaken, it should print:

Sun, 31 Dec 2000


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

int main(void)
{
    char str[80];
    struct tm tm;
    
    memset(&tm, 0, sizeof(tm));
    
    tm.tm_mday = 0;
    tm.tm_mon  = 0;
    tm.tm_year = 101;
        
    mktime(&tm);
        
    strftime(str, sizeof(str), "%a, %d %b %Y", &tm);
    puts(str);
    
    return 0;
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019