diff options
author | Steve Peters <steve@fisharerojo.org> | 2009-10-15 09:12:57 -0500 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2009-10-15 09:12:57 -0500 |
commit | 9e8c01f558a03902ff2f54935fd7e6dcc7ec656c (patch) | |
tree | 9a669a61c2e42a3225ea8523a0386f54cdc76ac7 /ext | |
parent | 867fa1e2da145229b4db2c6e8d5b51700c15f114 (diff) | |
download | perl-9e8c01f558a03902ff2f54935fd7e6dcc7ec656c.tar.gz |
POSIX::strftime() should be able to handle Unicode characters in the
format string the same as ASCII ones.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/POSIX/POSIX.pm | 2 | ||||
-rw-r--r-- | ext/POSIX/POSIX.xs | 6 | ||||
-rw-r--r-- | ext/POSIX/t/time.t | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/ext/POSIX/POSIX.pm b/ext/POSIX/POSIX.pm index 120769c623..b410fd995c 100644 --- a/ext/POSIX/POSIX.pm +++ b/ext/POSIX/POSIX.pm @@ -4,7 +4,7 @@ use warnings; our(@ISA, %EXPORT_TAGS, @EXPORT_OK, @EXPORT, $AUTOLOAD, %SIGRT) = (); -our $VERSION = "1.17"; +our $VERSION = "1.18"; use AutoLoader; diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 6de3588c63..14b24ff9c3 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -1781,7 +1781,7 @@ mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = -1) # ST(0) = sv_2mortal(newSVpv(...)) void strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) - char * fmt + SV * fmt int sec int min int hour @@ -1793,9 +1793,9 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) int isdst CODE: { - char *buf = my_strftime(fmt, sec, min, hour, mday, mon, year, wday, yday, isdst); + char *buf = my_strftime(SvPVutf8_nolen(fmt), sec, min, hour, mday, mon, year, wday, yday, isdst); if (buf) { - ST(0) = sv_2mortal(newSVpv(buf, 0)); + ST(0) = sv_2mortal(newSVpvn_utf8(buf, strlen(buf), SvUTF8(fmt))); Safefree(buf); } } diff --git a/ext/POSIX/t/time.t b/ext/POSIX/t/time.t index 103a161963..b1bdee2da0 100644 --- a/ext/POSIX/t/time.t +++ b/ext/POSIX/t/time.t @@ -4,7 +4,7 @@ use strict; use Config; use POSIX; -use Test::More tests => 9; +use Test::More tests => 10; # go to UTC to avoid DST issues around the world when testing. SUS3 says that # null should get you UTC, but some environments want the explicit names. @@ -39,6 +39,8 @@ my $orig_loc = setlocale(LC_TIME, "C") || die "Cannot setlocale() to C: $!"; my $jan_16 = 15 * 86400; is(ctime($jan_16), strftime("%a %b %d %H:%M:%S %Y\n", localtime($jan_16)), "get ctime() equal to strftime()"); +is(strftime("%Y年%m月%d日", localtime($jan_16)), "1970年01月16日", + "strftime() can handle unicode chars in the format string"); setlocale(LC_TIME, $orig_loc) || die "Cannot setlocale() back to orig: $!"; # clock() seems to have different definitions of what it does between POSIX |