* strftime.c (rb_strftime): The # flag should work with %a, %A, %b,

%B, and %h.  [ruby-dev:37162]
* test/ruby/test_time.rb (test_strftime): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2008-11-24 14:29:37 +00:00
Родитель 3380a05bd6
Коммит 361a713f96
3 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Mon Nov 24 23:27:28 2008 Shugo Maeda <shugo@ruby-lang.org>
* strftime.c (rb_strftime): The # flag should work with %a, %A, %b,
%B, and %h. [ruby-dev:37162]
* test/ruby/test_time.rb (test_strftime): ditto.
Mon Nov 24 23:16:32 2008 Yukihiro Matsumoto <matz@ruby-lang.org> Mon Nov 24 23:16:32 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* signal.c (register_sigaltstack): should not add external * signal.c (register_sigaltstack): should not add external

Просмотреть файл

@ -318,6 +318,10 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
continue; continue;
case 'a': /* abbreviated weekday name */ case 'a': /* abbreviated weekday name */
if (flags & BIT_OF(CHCASE)) {
flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE));
flags |= BIT_OF(UPPER);
}
if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6) if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6)
i = 1, tp = "?"; i = 1, tp = "?";
else else
@ -325,6 +329,10 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
break; break;
case 'A': /* full weekday name */ case 'A': /* full weekday name */
if (flags & BIT_OF(CHCASE)) {
flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE));
flags |= BIT_OF(UPPER);
}
if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6) if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6)
i = 1, tp = "?"; i = 1, tp = "?";
else else
@ -335,6 +343,10 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
case 'h': /* abbreviated month name */ case 'h': /* abbreviated month name */
#endif #endif
case 'b': /* abbreviated month name */ case 'b': /* abbreviated month name */
if (flags & BIT_OF(CHCASE)) {
flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE));
flags |= BIT_OF(UPPER);
}
if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11) if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11)
i = 1, tp = "?"; i = 1, tp = "?";
else else
@ -342,6 +354,10 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
break; break;
case 'B': /* full month name */ case 'B': /* full month name */
if (flags & BIT_OF(CHCASE)) {
flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE));
flags |= BIT_OF(UPPER);
}
if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11) if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11)
i = 1, tp = "?"; i = 1, tp = "?";
else else

Просмотреть файл

@ -461,5 +461,12 @@ class TestTime < Test::Unit::TestCase
assert_equal("\n", T2000.strftime("%1n")) assert_equal("\n", T2000.strftime("%1n"))
assert_equal(" \n", T2000.strftime("%3n")) assert_equal(" \n", T2000.strftime("%3n"))
assert_equal("00\n", T2000.strftime("%03n")) assert_equal("00\n", T2000.strftime("%03n"))
# [ruby-dev:37162]
assert_equal("SAT", T2000.strftime("%#a"))
assert_equal("SATURDAY", T2000.strftime("%#A"))
assert_equal("JAN", T2000.strftime("%#b"))
assert_equal("JANUARY", T2000.strftime("%#B"))
assert_equal("JAN", T2000.strftime("%#h"))
end end
end end