about summary refs log tree commit diff
path: root/src/libstd/time
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-12-02 13:55:35 -0700
committerSean Griffin <sean@seantheprogrammer.com>2015-12-02 13:55:35 -0700
commita69bcd885b5cf18ba05e0f81c091d3132534115c (patch)
tree251f341f91d3071efa8ccd2204a549b7cee7c957 /src/libstd/time
parentd5321f2abe7f6fadf8a3993b113ebb8ce9266fe9 (diff)
downloadrust-a69bcd885b5cf18ba05e0f81c091d3132534115c.tar.gz
rust-a69bcd885b5cf18ba05e0f81c091d3132534115c.zip
Ensure two `SystemTime`s are equal when nanos add to exactly 1B
Currently if you add a duration which should lead to 0 nanos and 1
additional second, we end up with no additional seconds, and 1000000000
nanos.
Diffstat (limited to 'src/libstd/time')
-rw-r--r--src/libstd/time/mod.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs
index d400d12e23f..1781461e3e3 100644
--- a/src/libstd/time/mod.rs
+++ b/src/libstd/time/mod.rs
@@ -303,6 +303,10 @@ mod tests {
         let eighty_years = second * 60 * 60 * 24 * 365 * 80;
         assert_almost_eq!(a - eighty_years + eighty_years, a);
         assert_almost_eq!(a - (eighty_years * 10) + (eighty_years * 10), a);
+
+        let one_second_from_epoch = UNIX_EPOCH + Duration::new(1, 0);
+        let one_second_from_epoch2 = UNIX_EPOCH + Duration::new(0, 999_999_999) + Duration::new(0, 1);
+        assert_eq!(one_second_from_epoch, one_second_from_epoch2);
     }
 
     #[test]