@@ -734,59 +734,6 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
734
734
}
735
735
736
736
fn do_strftime( format : & str , tm : & Tm ) -> ~str {
737
- fn days_in_year ( year : int ) -> i32 {
738
- if ( ( year % 4 == 0 ) && ( ( year % 100 != 0 ) || ( year % 400 == 0 ) ) ) {
739
- 366 /* Days in a leap year */
740
- } else {
741
- 365 /* Days in a non-leap year */
742
- }
743
- }
744
-
745
- fn iso_week_days ( yday : i32 , wday : i32 ) -> int {
746
- /* The number of days from the first day of the first ISO week of this
747
- * year to the year day YDAY with week day WDAY.
748
- * ISO weeks start on Monday. The first ISO week has the year's first
749
- * Thursday.
750
- * YDAY may be as small as yday_minimum.
751
- */
752
- let yday: int = yday as int ;
753
- let wday: int = wday as int ;
754
- let iso_week_start_wday: int = 1 ; /* Monday */
755
- let iso_week1_wday: int = 4 ; /* Thursday */
756
- let yday_minimum: int = 366 ;
757
- /* Add enough to the first operand of % to make it nonnegative. */
758
- let big_enough_multiple_of_7: int = ( yday_minimum / 7 + 2 ) * 7 ;
759
-
760
- yday - ( yday - wday + iso_week1_wday + big_enough_multiple_of_7) % 7
761
- + iso_week1_wday - iso_week_start_wday
762
- }
763
-
764
- fn iso_week( ch : char , tm : & Tm ) -> ~str {
765
- let mut year: int = tm. tm_year as int + 1900 ;
766
- let mut days: int = iso_week_days ( tm. tm_yday , tm. tm_wday ) ;
767
-
768
- if ( days < 0 ) {
769
- /* This ISO week belongs to the previous year. */
770
- year -= 1 ;
771
- days = iso_week_days ( tm. tm_yday + ( days_in_year ( year) ) , tm. tm_wday ) ;
772
- } else {
773
- let d: int = iso_week_days ( tm. tm_yday - ( days_in_year ( year) ) ,
774
- tm. tm_wday ) ;
775
- if ( 0 <= d) {
776
- /* This ISO week belongs to the next year. */
777
- year += 1 ;
778
- days = d;
779
- }
780
- }
781
-
782
- match ch {
783
- 'G' => format ! ( "{}" , year) ,
784
- 'g' => format ! ( "{:02d}" , ( year % 100 + 100 ) % 100 ) ,
785
- 'V' => format ! ( "{:02d}" , days / 7 + 1 ) ,
786
- _ => ~""
787
- }
788
- }
789
-
790
737
fn parse_type ( ch : char , tm : & Tm ) -> ~str {
791
738
//FIXME (#2350): Implement missing types.
792
739
let die = || format ! ( "strftime: can't understand this format {} " , ch) ;
@@ -865,8 +812,8 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
865
812
parse_type( 'm' , tm) ,
866
813
parse_type( 'd' , tm) )
867
814
}
868
- 'G' => iso_week ( 'G' , tm ) ,
869
- 'g' => iso_week ( 'g' , tm ) ,
815
+ // 'G' {}
816
+ // 'g' {}
870
817
'H' => format ! ( "{:02d}" , tm. tm_hour) ,
871
818
'I' => {
872
819
let mut h = tm. tm_hour ;
@@ -908,12 +855,12 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
908
855
parse_type( 'S' , tm) )
909
856
}
910
857
't' => ~"\t ",
911
- 'U' => format ! ( "{:02d}" , ( tm . tm_yday - tm . tm_wday + 7 ) / 7 ) ,
858
+ // 'U' {}
912
859
'u' => {
913
860
let i = tm. tm_wday as int ;
914
861
( if i == 0 { 7 } else { i } ) . to_str ( )
915
862
}
916
- 'V' => iso_week ( 'V' , tm ) ,
863
+ // 'V' {}
917
864
'v' => {
918
865
format ! ( "{}-{}-{}" ,
919
866
parse_type( 'e' , tm) ,
@@ -1275,8 +1222,8 @@ mod tests {
1275
1222
assert_eq!(local.strftime(" %e"), ~" 13 ");
1276
1223
assert_eq!(local.strftime(" %f"), ~" 000054321 ");
1277
1224
assert_eq!(local.strftime(" %F "), ~" 2009 -02 -13 ");
1278
- assert_eq !(local.strftime(" %G "), ~ " 2009 ");
1279
- assert_eq !(local.strftime(" %g"), ~ " 09 ");
1225
+ // assert !(local.strftime(" %G ") == " 2009 ");
1226
+ // assert !(local.strftime(" %g") == " 09 ");
1280
1227
assert_eq!(local.strftime(" %H "), ~" 15 ");
1281
1228
assert_eq!(local.strftime(" %I "), ~" 03 ");
1282
1229
assert_eq!(local.strftime(" %j"), ~" 044 ");
@@ -1293,9 +1240,9 @@ mod tests {
1293
1240
assert_eq!(local.strftime(" %s"), ~" 1234567890 ");
1294
1241
assert_eq!(local.strftime(" %T "), ~" 15 : 31 : 30 ");
1295
1242
assert_eq!(local.strftime(" %t"), ~"\t " ) ;
1296
- assert_eq ! ( local. strftime( "%U" ) , ~ "06 ");
1243
+ // assert !(local.strftime("%U") == "06");
1297
1244
assert_eq ! ( local. strftime( "%u" ) , ~"5 ");
1298
- assert_eq !(local.strftime(" %V "), ~ " 07 ");
1245
+ // assert !(local.strftime(" %V ") == " 07 ");
1299
1246
assert_eq!(local.strftime(" %v"), ~" 13 -Feb -2009 ");
1300
1247
// assert!(local.strftime(" %W ") == " 06 ");
1301
1248
assert_eq!(local.strftime(" %w"), ~" 5 ");
0 commit comments