- Subject: Leading zero padding in time formats.
- From: Morten Bo Johansen <mojo@xxxxxxxx>
- Date: Tue, 14 Jan 2003 19:24:56 +0100
Hi all,
I need to produce a string with this format
   2003-01-14 15:44+0100
but I got problems with the leading zero padding in both the
month and day and also in the timezone offset so the string I am
able to produce looks like this:
   2003-1-14 15:44+100
The line to get the date and time looks like this:
   
   variable tm = sprintf ("%d-%d-%d %d:%d", 1900 + tm.tm_year, 1+tm.tm_mon, 
                          tm.tm_mday, tm.tm_hour, tm.tm_min);
   
The lines to get the offset looks like this:
   
   variable gm, gmhour, lm, lmhour, off;
   gm = (gmtime (_time ()));
   gmhour = gm.tm_hour;
   lm = (localtime (_time ()));
   lmhour = lm.tm_hour;
   off = (lmhour-gmhour)*100;
Anyone knows?
Thanks,
Morten
-- 
"How beautiful it is to do nothing and then rest afterward"
                                         (Spanish Proverb)
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
  [2003 date index]
  [2003 thread index]
  
  [Thread Prev] [Thread Next]
      
  [Date Prev] [Date Next]