Skip to content

Commit d2a63ab

Browse files
committed
---
yaml --- r: 127867 b: refs/heads/auto c: 18f75a9 h: refs/heads/master i: 127865: 676fdbd 127863: 48ba648 v: v3
1 parent 13b0cef commit d2a63ab

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: dc8b23bc1ffa227bdc7b95206c7b2dabe32818ac
16+
refs/heads/auto: 18f75a9197a5b535f9804901bfefbaffe373d689
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libstd/time.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ macro_rules! earlyexit(
2929
($e:expr) => (match $e { Some(v) => v, None => return None })
3030
)
3131

32-
/// ISO 8601 duration
32+
/// The representation of a span of time.
33+
///
34+
/// This type has nanosecond precision, and conforms to the ISO 8601
35+
/// standard for Date interchange.
3336
#[deriving(PartialEq, Eq, PartialOrd, Ord)]
3437
pub struct Duration {
3538
days: i32,
@@ -38,6 +41,7 @@ pub struct Duration {
3841
}
3942

4043
impl Duration {
44+
/// Create a new `Duration`.
4145
pub fn new(days: i32, secs: i32, nanos: i32) -> Option<Duration> {
4246
let (secs_, nanos) = div_mod_floor(nanos, NANOS_PER_SEC);
4347
let secs = earlyexit!(secs.checked_add(&secs_));
@@ -46,67 +50,78 @@ impl Duration {
4650
Some(Duration { days: days, secs: secs as u32, nanos: nanos as u32 })
4751
}
4852

53+
/// Create a new `Duration` from an integer number of weeks.
4954
#[inline]
5055
pub fn weeks(weeks: i32) -> Duration {
5156
Duration::days(weeks * 7)
5257
}
5358

59+
/// Create a new `Duration` from an integer number of days.
5460
#[inline]
5561
pub fn days(days: i32) -> Duration {
5662
let days = days.to_i32().expect("Duration::days out of bounds");
5763
Duration { days: days, secs: 0, nanos: 0 }
5864
}
5965

66+
/// Create a new `Duration` from an integer number of hours.
6067
#[inline]
6168
pub fn hours(hours: i32) -> Duration {
6269
let (days, hours) = div_mod_floor(hours, (SECS_PER_DAY / 3600));
6370
let secs = hours * 3600;
6471
Duration { secs: secs as u32, ..Duration::days(days) }
6572
}
6673

74+
/// Create a new `Duration` from an integer number of minutes.
6775
#[inline]
6876
pub fn minutes(mins: i32) -> Duration {
6977
let (days, mins) = div_mod_floor(mins, (SECS_PER_DAY / 60));
7078
let secs = mins * 60;
7179
Duration { secs: secs as u32, ..Duration::days(days) }
7280
}
7381

82+
/// Create a new `Duration` from an integer number of seconds.
7483
#[inline]
7584
pub fn seconds(secs: i32) -> Duration {
7685
let (days, secs) = div_mod_floor(secs, SECS_PER_DAY);
7786
Duration { secs: secs as u32, ..Duration::days(days) }
7887
}
7988

89+
/// Create a new `Duration` from an integer number of milliseconds.
8090
#[inline]
8191
pub fn milliseconds(millis: i32) -> Duration {
8292
let (secs, millis) = div_mod_floor(millis, (NANOS_PER_SEC / 1_000_000));
8393
let nanos = millis * 1_000_000;
8494
Duration { nanos: nanos as u32, ..Duration::seconds(secs) }
8595
}
8696

97+
/// Create a new `Duration` from an integer number of microseconds.
8798
#[inline]
8899
pub fn microseconds(micros: i32) -> Duration {
89100
let (secs, micros) = div_mod_floor(micros, (NANOS_PER_SEC / 1_000));
90101
let nanos = micros * 1_000;
91102
Duration { nanos: nanos as u32, ..Duration::seconds(secs) }
92103
}
93104

105+
/// Create a new `Duration` from an integer number of nanoseconds.
94106
#[inline]
95107
pub fn nanoseconds(nanos: i32) -> Duration {
96108
let (secs, nanos) = div_mod_floor(nanos, NANOS_PER_SEC);
97109
Duration { nanos: nanos as u32, ..Duration::seconds(secs) }
98110
}
99111

112+
/// Return the number of whole days in the `Duration`.
100113
#[inline]
101114
pub fn ndays(&self) -> i32 {
102115
self.days as i32
103116
}
104117

118+
/// Return the fractional number of days in the `Duration` as seconds.
105119
#[inline]
106120
pub fn nseconds(&self) -> u32 {
107121
self.secs as u32
108122
}
109123

124+
/// Return the fractional number of seconds in the `Duration` as nanoseconds.
110125
#[inline]
111126
pub fn nnanoseconds(&self) -> u32 {
112127
self.nanos as u32

0 commit comments

Comments
 (0)