summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSpider Boardman <spider@orb.nashua.nh.us>1998-09-30 11:12:09 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-10-02 04:05:36 +0000
commite44f695ee9be4f523999589b52c7c8e9ddc1bed9 (patch)
treedf41277dc9980a69cbd69e0bc358ffe1d04efd8c /ext
parentf7ab18e91b2eff4db1bb9e684aea7326f2222811 (diff)
downloadperl-e44f695ee9be4f523999589b52c7c8e9ddc1bed9.tar.gz
normalize tm struct passed to strftime() with mktime()
Message-Id: <199809301912.PAA26119@Orb.Nashua.NH.US> Subject: [PATCH 5.005_52] Re: POSIX::strftime returns incorrect date p4raw-id: //depot/perl@1914
Diffstat (limited to 'ext')
-rw-r--r--ext/POSIX/POSIX.pod7
-rw-r--r--ext/POSIX/POSIX.xs3
2 files changed, 6 insertions, 4 deletions
diff --git a/ext/POSIX/POSIX.pod b/ext/POSIX/POSIX.pod
index 4726487b47..6a4a61aca6 100644
--- a/ext/POSIX/POSIX.pod
+++ b/ext/POSIX/POSIX.pod
@@ -1009,13 +1009,14 @@ Convert date and time information to string. Returns the string.
Synopsis:
- strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
+ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero.
I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The
-year (C<year>) is given in years since 1900. I.e. The year 1995 is 95; the
+year (C<year>) is given in years since 1900. I.e., the year 1995 is 95; the
year 2001 is 101. Consult your system's C<strftime()> manpage for details
-about these and the other arguments.
+about these and the other arguments. The given arguments are made consistent
+by calling C<mktime()> before calling your system's C<strftime()> function.
The string for Tuesday, December 12, 1995.
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 6958c00c47..1840ca4034 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -3591,7 +3591,7 @@ mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
RETVAL
char *
-strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
+strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
char * fmt
int sec
int min
@@ -3617,6 +3617,7 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
mytm.tm_wday = wday;
mytm.tm_yday = yday;
mytm.tm_isdst = isdst;
+ (void) mktime(&mytm);
len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
}