@@ -788,7 +788,6 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
788
788
}
789
789
790
790
fn parse_type ( ch: char, tm: & Tm ) -> ~str {
791
- //FIXME (#2350): Implement missing types.
792
791
let die = || format ! ( "strftime: can't understand this format {} " , ch) ;
793
792
match ch {
794
793
'A' => match tm. tm_wday as int {
@@ -920,10 +919,9 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
920
919
parse_type( 'b' , tm) ,
921
920
parse_type( 'Y' , tm) )
922
921
}
923
- //'W' {}
922
+ 'W' => format ! ( "{:02d}" , ( tm. tm_yday - ( tm. tm_wday - 1 + 7 ) % 7 + 7 )
923
+ / 7 ) ,
924
924
'w' => ( tm. tm_wday as int ) . to_str ( ) ,
925
- //'X' {}
926
- //'x' {}
927
925
'Y' => ( tm. tm_year as int + 1900 ) . to_str ( ) ,
928
926
'y' => format ! ( "{:02d}" , ( tm. tm_year as int + 1900 ) % 100 ) ,
929
927
'Z' => tm. tm_zone . clone ( ) ,
@@ -934,7 +932,7 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
934
932
m -= h * 60_i32 ;
935
933
format ! ( "{}{:02d}{:02d}" , sign, h, m)
936
934
}
937
- // '+' {}
935
+ '+' => tm . rfc3339 ( ) ,
938
936
'%' => ~"%",
939
937
_ => die()
940
938
}
@@ -1297,12 +1295,13 @@ mod tests {
1297
1295
assert_eq!(local.strftime(" %u"), ~" 5 ");
1298
1296
assert_eq!(local.strftime(" %V "), ~" 07 ");
1299
1297
assert_eq!(local.strftime(" %v"), ~" 13 -Feb -2009 ");
1300
- // assert !(local.strftime(" %W ") == " 06 ");
1298
+ assert_eq !(local.strftime(" %W "), ~ " 06 ");
1301
1299
assert_eq!(local.strftime(" %w"), ~" 5 ");
1302
- // handle " %X "
1303
- // handle " %x"
1300
+ assert_eq!(local.strftime( " %X "), ~" 15 : 31 : 30 "); // FIXME (#2350): support locale
1301
+ assert_eq!(local.strftime( " %x"), ~" 02 / 13 / 09 "); // FIXME (#2350): support locale
1304
1302
assert_eq!(local.strftime(" %Y "), ~" 2009 ");
1305
1303
assert_eq!(local.strftime(" %y"), ~" 09 ");
1304
+ assert_eq!(local.strftime(" %+"), ~" 2009 -02 -13 T15 : 31 : 30 -08 : 00 ");
1306
1305
1307
1306
// FIXME (#2350): We should probably standardize on the timezone
1308
1307
// abbreviation.
0 commit comments