Skip to content

Commit 1c3a575

Browse files
committed
---
yaml --- r: 157609 b: refs/heads/snap-stage3 c: b8e7c4f h: refs/heads/master i: 157607: 0df5c2c v: v3
1 parent d62572c commit 1c3a575

File tree

4 files changed

+194
-129
lines changed

4 files changed

+194
-129
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 065caf34f5ff29e04605f95d9c5d511af219439a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 15dd90b6475c7a44c9b95044c91519d9464bbcc4
4+
refs/heads/snap-stage3: b8e7c4fcb9655ff92f8f2feba4ba4221646acc6f
55
refs/heads/try: 0ee4d8b0b112c608646fa75463ab4dc59132efd9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/llvm.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ endif
3838
# the stamp in the source dir.
3939
$$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
4040
@$$(call E, make: cleaning llvm)
41-
$(Q)$(MAKE) clean-llvm
41+
$(Q)$(MAKE) clean-llvm$(1)
4242
@$$(call E, make: done cleaning llvm)
4343
touch $$@
4444

branches/snap-stage3/src/libstd/time/duration.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -317,29 +317,26 @@ impl Div<i32,Duration> for Duration {
317317

318318
impl fmt::Show for Duration {
319319
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
320-
// technically speaking, negative duration is not valid ISO 8601,
321-
// but we need to print it anyway.
322-
let (abs, sign) = if self.secs < 0 { (-self, "-") } else { (*self, "") };
323-
324-
let days = abs.secs / SECS_PER_DAY;
325-
let secs = abs.secs - days * SECS_PER_DAY;
320+
let days = self.num_days();
321+
let secs = self.secs - days * SECS_PER_DAY;
326322
let hasdate = days != 0;
327-
let hastime = (secs != 0 || abs.nanos != 0) || !hasdate;
328-
329-
try!(write!(f, "{}P", sign));
323+
let hastime = (secs != 0 || self.nanos != 0) || !hasdate;
330324

325+
try!(write!(f, "P"));
331326
if hasdate {
327+
// technically speaking the negative part is not the valid ISO 8601,
328+
// but we need to print it anyway.
332329
try!(write!(f, "{}D", days));
333330
}
334331
if hastime {
335-
if abs.nanos == 0 {
332+
if self.nanos == 0 {
336333
try!(write!(f, "T{}S", secs));
337-
} else if abs.nanos % NANOS_PER_MILLI == 0 {
338-
try!(write!(f, "T{}.{:03}S", secs, abs.nanos / NANOS_PER_MILLI));
339-
} else if abs.nanos % NANOS_PER_MICRO == 0 {
340-
try!(write!(f, "T{}.{:06}S", secs, abs.nanos / NANOS_PER_MICRO));
334+
} else if self.nanos % NANOS_PER_MILLI == 0 {
335+
try!(write!(f, "T{}.{:03}S", secs, self.nanos / NANOS_PER_MILLI));
336+
} else if self.nanos % NANOS_PER_MICRO == 0 {
337+
try!(write!(f, "T{}.{:06}S", secs, self.nanos / NANOS_PER_MICRO));
341338
} else {
342-
try!(write!(f, "T{}.{:09}S", secs, abs.nanos));
339+
try!(write!(f, "T{}.{:09}S", secs, self.nanos));
343340
}
344341
}
345342
Ok(())
@@ -543,15 +540,13 @@ mod tests {
543540
let d: Duration = Zero::zero();
544541
assert_eq!(d.to_string(), "PT0S".to_string());
545542
assert_eq!(Duration::days(42).to_string(), "P42D".to_string());
546-
assert_eq!(Duration::days(-42).to_string(), "-P42D".to_string());
543+
assert_eq!(Duration::days(-42).to_string(), "P-42D".to_string());
547544
assert_eq!(Duration::seconds(42).to_string(), "PT42S".to_string());
548545
assert_eq!(Duration::milliseconds(42).to_string(), "PT0.042S".to_string());
549546
assert_eq!(Duration::microseconds(42).to_string(), "PT0.000042S".to_string());
550547
assert_eq!(Duration::nanoseconds(42).to_string(), "PT0.000000042S".to_string());
551548
assert_eq!((Duration::days(7) + Duration::milliseconds(6543)).to_string(),
552549
"P7DT6.543S".to_string());
553-
assert_eq!(Duration::seconds(-86401).to_string(), "-P1DT1S".to_string());
554-
assert_eq!(Duration::nanoseconds(-1).to_string(), "-PT0.000000001S".to_string());
555550

556551
// the format specifier should have no effect on `Duration`
557552
assert_eq!(format!("{:30}", Duration::days(1) + Duration::milliseconds(2345)),

0 commit comments

Comments
 (0)