@@ -321,33 +321,6 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
321
321
Some ( ( value, pos) )
322
322
}
323
323
324
- fn match_fractional_seconds ( ss : & str , pos : uint ) -> ( i32 , uint ) {
325
- let len = ss. len ( ) ;
326
- let mut value = 0_i32 ;
327
- let mut multiplier = NSEC_PER_SEC / 10 ;
328
- let mut pos = pos;
329
-
330
- loop {
331
- if pos >= len {
332
- break ;
333
- }
334
- let range = ss. char_range_at ( pos) ;
335
-
336
- match range. ch {
337
- '0' .. '9' => {
338
- pos = range. next ;
339
- // This will drop digits after the nanoseconds place
340
- let digit = range. ch as i32 - '0' as i32 ;
341
- value += digit * multiplier;
342
- multiplier /= 10 ;
343
- }
344
- _ => break
345
- }
346
- }
347
-
348
- ( value, pos)
349
- }
350
-
351
324
fn match_digits_in_range ( ss : & str , pos : uint , digits : uint , ws : bool ,
352
325
min : i32 , max : i32 ) -> Option < ( i32 , uint ) > {
353
326
match match_digits ( ss, pos, digits, ws) {
@@ -468,11 +441,6 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
468
441
Some ( item) => { let ( v, pos) = item; tm. tm_mday = v; Ok ( pos) }
469
442
None => Err ( ~"Invalid day of the month")
470
443
} ,
471
- 'f' => {
472
- let ( val, pos) = match_fractional_seconds ( s, pos) ;
473
- tm. tm_nsec = val;
474
- Ok ( pos)
475
- }
476
444
'F' => {
477
445
parse_type ( s, pos, 'Y' , & mut * tm)
478
446
. chain ( |pos| parse_char ( s, pos, '-' ) )
@@ -805,7 +773,6 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
805
773
}
806
774
'd' => fmt ! ( "%02d" , tm. tm_mday as int) ,
807
775
'e' => fmt ! ( "%2d" , tm. tm_mday as int) ,
808
- 'f' => fmt ! ( "%09d" , tm. tm_nsec as int) ,
809
776
'F' => {
810
777
fmt ! ( "%s-%s-%s" ,
811
778
parse_type( 'Y' , tm) ,
@@ -1044,12 +1011,12 @@ mod tests {
1044
1011
Err(_) => ()
1045
1012
}
1046
1013
1047
- let format = " %a %b %e %T . %f %Y ";
1014
+ let format = " %a %b %e %T %Y ";
1048
1015
assert_eq!(strptime(" ", format), Err(~" Invalid time"));
1049
1016
assert!(strptime(" Fri Feb 13 15 : 31 : 30 ", format)
1050
1017
== Err(~" Invalid time"));
1051
1018
1052
- match strptime(" Fri Feb 13 15 : 31 : 30.01234 2009 ", format) {
1019
+ match strptime(" Fri Feb 13 15 : 31 : 30 2009 ", format) {
1053
1020
Err(e) => fail!(e),
1054
1021
Ok(ref tm) => {
1055
1022
assert!(tm.tm_sec == 30_i32);
@@ -1063,7 +1030,7 @@ mod tests {
1063
1030
assert!(tm.tm_isdst == 0_i32);
1064
1031
assert!(tm.tm_gmtoff == 0_i32);
1065
1032
assert!(tm.tm_zone == ~" ");
1066
- assert!(tm.tm_nsec == 12340000_i32 );
1033
+ assert!(tm.tm_nsec == 0_i32 );
1067
1034
}
1068
1035
}
1069
1036
@@ -1220,7 +1187,6 @@ mod tests {
1220
1187
assert_eq!(local.strftime(" %D "), ~" 02 /13 /09 ");
1221
1188
assert_eq!(local.strftime(" %d"), ~" 13 ");
1222
1189
assert_eq!(local.strftime(" %e"), ~" 13 ");
1223
- assert_eq!(local.strftime(" %f"), ~" 000054321 ");
1224
1190
assert_eq!(local.strftime(" %F "), ~" 2009 -02 -13 ");
1225
1191
// assert!(local.strftime(" %G ") == " 2009 ");
1226
1192
// assert!(local.strftime(" %g") == " 09 ");
0 commit comments