Skip to content

Commit 6d1376f

Browse files
committed
---
yaml --- r: 95140 b: refs/heads/dist-snap c: ee114b6 h: refs/heads/master v: v3
1 parent fdddbb4 commit 6d1376f

File tree

12 files changed

+172
-228
lines changed

12 files changed

+172
-228
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: aaeb7605c9aeb09374563ac7a427dfbd7d1f7892
9+
refs/heads/dist-snap: ee114b6cb15049a6be77c70c24c42db23e675e54
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/time.rs

Lines changed: 8 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -734,59 +734,6 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
734734
}
735735

736736
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-
790737
fn parse_type(ch: char, tm: &Tm) -> ~str {
791738
//FIXME (#2350): Implement missing types.
792739
let die = || format!("strftime: can't understand this format {} ", ch);
@@ -865,8 +812,8 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
865812
parse_type('m', tm),
866813
parse_type('d', tm))
867814
}
868-
'G' => iso_week('G', tm),
869-
'g' => iso_week('g', tm),
815+
//'G' {}
816+
//'g' {}
870817
'H' => format!("{:02d}", tm.tm_hour),
871818
'I' => {
872819
let mut h = tm.tm_hour;
@@ -908,12 +855,12 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
908855
parse_type('S', tm))
909856
}
910857
't' => ~"\t",
911-
'U' => format!("{:02d}", (tm.tm_yday - tm.tm_wday + 7) / 7),
858+
//'U' {}
912859
'u' => {
913860
let i = tm.tm_wday as int;
914861
(if i == 0 { 7 } else { i }).to_str()
915862
}
916-
'V' => iso_week('V', tm),
863+
//'V' {}
917864
'v' => {
918865
format!("{}-{}-{}",
919866
parse_type('e', tm),
@@ -1275,8 +1222,8 @@ mod tests {
12751222
assert_eq!(local.strftime("%e"), ~"13");
12761223
assert_eq!(local.strftime("%f"), ~"000054321");
12771224
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");
12801227
assert_eq!(local.strftime("%H"), ~"15");
12811228
assert_eq!(local.strftime("%I"), ~"03");
12821229
assert_eq!(local.strftime("%j"), ~"044");
@@ -1293,9 +1240,9 @@ mod tests {
12931240
assert_eq!(local.strftime("%s"), ~"1234567890");
12941241
assert_eq!(local.strftime("%T"), ~"15:31:30");
12951242
assert_eq!(local.strftime("%t"), ~"\t");
1296-
assert_eq!(local.strftime("%U"), ~"06");
1243+
// assert!(local.strftime("%U") == "06");
12971244
assert_eq!(local.strftime("%u"), ~"5");
1298-
assert_eq!(local.strftime("%V"), ~"07");
1245+
// assert!(local.strftime("%V") == "07");
12991246
assert_eq!(local.strftime("%v"), ~"13-Feb-2009");
13001247
// assert!(local.strftime("%W") == "06");
13011248
assert_eq!(local.strftime("%w"), ~"5");

0 commit comments

Comments
 (0)