@@ -788,7 +788,6 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
788788 }
789789
790790 fn parse_type ( ch: char, tm: & Tm ) -> ~str {
791- //FIXME (#2350): Implement missing types.
792791 let die = || format ! ( "strftime: can't understand this format {} " , ch) ;
793792 match ch {
794793 'A' => match tm. tm_wday as int {
@@ -920,10 +919,9 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
920919 parse_type( 'b' , tm) ,
921920 parse_type( 'Y' , tm) )
922921 }
923- //'W' {}
922+ 'W' => format ! ( "{:02d}" , ( tm. tm_yday - ( tm. tm_wday - 1 + 7 ) % 7 + 7 )
923+ / 7 ) ,
924924 'w' => ( tm. tm_wday as int ) . to_str ( ) ,
925- //'X' {}
926- //'x' {}
927925 'Y' => ( tm. tm_year as int + 1900 ) . to_str ( ) ,
928926 'y' => format ! ( "{:02d}" , ( tm. tm_year as int + 1900 ) % 100 ) ,
929927 'Z' => tm. tm_zone . clone ( ) ,
@@ -934,7 +932,7 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
934932 m -= h * 60_i32 ;
935933 format ! ( "{}{:02d}{:02d}" , sign, h, m)
936934 }
937- // '+' {}
935+ '+' => tm . rfc3339 ( ) ,
938936 '%' => ~"%",
939937 _ => die()
940938 }
@@ -1297,12 +1295,13 @@ mod tests {
12971295 assert_eq!(local.strftime(" %u"), ~" 5 ");
12981296 assert_eq!(local.strftime(" %V "), ~" 07 ");
12991297 assert_eq!(local.strftime(" %v"), ~" 13 -Feb -2009 ");
1300- // assert !(local.strftime(" %W ") == " 06 ");
1298+ assert_eq !(local.strftime(" %W "), ~ " 06 ");
13011299 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
13041302 assert_eq!(local.strftime(" %Y "), ~" 2009 ");
13051303 assert_eq!(local.strftime(" %y"), ~" 09 ");
1304+ assert_eq!(local.strftime(" %+"), ~" 2009 -02 -13 T15 : 31 : 30 -08 : 00 ");
13061305
13071306 // FIXME (#2350): We should probably standardize on the timezone
13081307 // abbreviation.
0 commit comments