I'm using this on an x-axis with time:
set format x "%l %p"
And I get "0 AM" (or "0 PM") where it should read "12 AM". In other
words, the %l token returns 0-11 instead of 1-12.
Since the Gnuplot docs mention that your system's strftime affects what
tags available, I'll mention that I'm using FreeBSD (4.8 branch) and
using strftime through perl directly doesn't have this bug, e.g.:
# perl
use POSIX 'strftime';
$now = time;
$now = $now - ($now % 43200); # round off to 12 hr interval
$formatted = strftime "TIME: %l %p", gmtime($now);
print "$formatted\n";
^D
TIME: 12 PM
#
And of course: gnuplot-4.0.0_2 (i.e. 4.0.0, FreeBSD port patchlevel 2).
> I'm using this on an x-axis with time:
> set format x "%l %p"
> And I get "0 AM" (or "0 PM") where it should read "12 AM". In other
> words, the %l token returns 0-11 instead of 1-12.
I must admit I felt badly tempted to just reply "what person in their
right mind would use this silly AM/PM stuff anyway..." ;-)
But yes, that may be a bug. The documentation says that %l prints
something in the range 0--12, when it actually never outputs 12.
The system strftime() almost certainly won't have anything to do with
it (the switch USE_SYSTEM_TIME is not set by any current build). The
code that actually gets used is gstrftime() in src/time.c
--
Hans-Bernhard Broeker (bro...@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Anyway, looking at time.c, it looks like a one-line patch that even I
could do. Since no one that I'm aware of uses zero in 12-hour time,
I'll offer a patch as suggested in the FAQ.
There is no "12 AM" or "12 PM". There is 12 Noon, and 12
Midnight.
--
Grant Edwards grante Yow! I just heard the
at SEVENTIES were over!! And
visi.com I was just getting in touch
with my LEISURE SUIT!!
That's my mouth: here's my money (less linewrap garbling by gmail):
--- gnuplot-4.0.0/src/time.c.orig Fri Jan 28 23:43:13 2005
+++ gnuplot-4.0.0/src/time.c Fri Jan 28 23:53:05 2005
@@ -525,7 +525,7 @@
break;
case 'I':
- FORMAT_STRING(1, 2, tm->tm_hour % 12); /* %02d */
+ FORMAT_STRING(0, 2, (tm->tm_hour ? tm->tm_hour % 12 :
12)); /* %2d */
break;
case 'j':
@@ -538,7 +538,7 @@
break;
case 'l':
- FORMAT_STRING(0, 2, tm->tm_hour % 12); /* %2d */
+ FORMAT_STRING(0, 2, (tm->tm_hour ? tm->tm_hour % 12 :
12)); /* %2d */
break;
case 'm':
case 'I':
- FORMAT_STRING(1, 2, tm->tm_hour % 12); /* %02d */
+ FORMAT_STRING(0, 2, (tm->tm_hour % 12 ? tm->tm_hour %
12 : 12));/* %2d */
break;
case 'j':
@@ -538,7 +538,7 @@
break;
case 'l':
- FORMAT_STRING(0, 2, tm->tm_hour % 12); /* %2d */
+ FORMAT_STRING(0, 2, (tm->tm_hour % 12 ? tm->tm_hour %
12 : 12)); /* %2d */
break;
case 'm':
---------------
And these gnuplot commands demonstrate the fix:
set xdata time
set format x "%l %p"
set timefmt "%s"
plot "-" using 1:2 with linespoints
1106953200 5
1106956800 1
1106960400 2
1106964000 3
1106967600 4
1106971200 3
1106974800 8
1106978400 4
1106982000 9
1106985600 1
1106989200 0
1106992800 3
1106996400 9
1107000000 5
1107003600 4
gnupl...@lists.sourceforge.net
Unrouteable address
And spamassassin sez:
0.0 RCVD_BY_IP Received by mail server with no name
Boo. Well I hope my patch makes it in, because I don't like maintaining
patches.
Apparently sourceforge spam filters are on the side of paranoid?