diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-28 17:06:20 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-28 17:06:20 +0000 |
commit | 63846d48a9b2044ad2fb3062ca8551de078d3508 (patch) | |
tree | b1691c2811825b84b9da5fd326abcc0d2034dd54 /strftime.c | |
parent | c23ec90e813457ec4db5d02677cdb358743974b5 (diff) | |
download | ruby-63846d48a9b2044ad2fb3062ca8551de078d3508.tar.gz |
* strftime.c (rb_strftime): supported %s and %P.
* time.c (time_strftime): ditto.
* test/ruby/test_time.rb (test_strftime): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'strftime.c')
-rw-r--r-- | strftime.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/strftime.c b/strftime.c index fa0e6e6a69..e559c05dd1 100644 --- a/strftime.c +++ b/strftime.c @@ -376,8 +376,10 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept FMT('0', 2, "d", i); continue; - case 'p': /* am or pm based on 12-hour clock */ - if (flags & BIT_OF(CHCASE)) { + case 'p': /* AM or PM based on 12-hour clock */ + case 'P': /* am or pm based on 12-hour clock */ + if ((*format == 'p' && (flags & BIT_OF(CHCASE))) || + (*format == 'P' && !(flags & BIT_OF(CHCASE)))) { flags &= ~(BIT_OF(UPPER)|BIT_OF(CHCASE)); flags |= BIT_OF(LOWER); } @@ -389,6 +391,10 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept i = 2; break; + case 's': + FMT(' ', 1, "d", (int) ts->tv_sec); + continue; + case 'S': /* second, 00 - 60 */ i = range(0, timeptr->tm_sec, 60); FMT('0', 2, "d", i); |