From c463772ebdbfca65017ac1bc2c8322d229b291a9 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Tue, 1 Oct 2013 22:20:46 -0400 Subject: [PATCH] extra: %U support in time::strftime Fixes #2350 --- src/libextra/time.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libextra/time.rs b/src/libextra/time.rs index 7f08fcd908aea..34b50588ae2f4 100644 --- a/src/libextra/time.rs +++ b/src/libextra/time.rs @@ -855,7 +855,7 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str { parse_type('S', tm)) } 't' => ~"\t", - //'U' {} + 'U' => format!("{:02d}", (tm.tm_yday - tm.tm_wday + 7) / 7), 'u' => { let i = tm.tm_wday as int; (if i == 0 { 7 } else { i }).to_str() @@ -1240,7 +1240,7 @@ mod tests { assert_eq!(local.strftime("%s"), ~"1234567890"); assert_eq!(local.strftime("%T"), ~"15:31:30"); assert_eq!(local.strftime("%t"), ~"\t"); - // assert!(local.strftime("%U") == "06"); + assert_eq!(local.strftime("%U"), ~"06"); assert_eq!(local.strftime("%u"), ~"5"); // assert!(local.strftime("%V") == "07"); assert_eq!(local.strftime("%v"), ~"13-Feb-2009");