Skip to content

Commit c463772

Browse files
committed
extra: %U support in time::strftime
Fixes #2350
1 parent c8cdabc commit c463772

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libextra/time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
855855
parse_type('S', tm))
856856
}
857857
't' => ~"\t",
858-
//'U' {}
858+
'U' => format!("{:02d}", (tm.tm_yday - tm.tm_wday + 7) / 7),
859859
'u' => {
860860
let i = tm.tm_wday as int;
861861
(if i == 0 { 7 } else { i }).to_str()
@@ -1240,7 +1240,7 @@ mod tests {
12401240
assert_eq!(local.strftime("%s"), ~"1234567890");
12411241
assert_eq!(local.strftime("%T"), ~"15:31:30");
12421242
assert_eq!(local.strftime("%t"), ~"\t");
1243-
// assert!(local.strftime("%U") == "06");
1243+
assert_eq!(local.strftime("%U"), ~"06");
12441244
assert_eq!(local.strftime("%u"), ~"5");
12451245
// assert!(local.strftime("%V") == "07");
12461246
assert_eq!(local.strftime("%v"), ~"13-Feb-2009");

0 commit comments

Comments
 (0)