Skip to content

Commit 29b16a2

Browse files
ZexbeMark-Simulacrum
authored andcommitted
Make sure the seconds add up to less then a day
1 parent 3e1b568 commit 29b16a2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/posts.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ impl Post {
144144
}
145145

146146
fn build_post_time(year: u32, month: u32, day: u32, seconds: u32) -> String {
147+
let seconds = Duration::seconds(seconds as i64);
148+
if seconds >= Duration::days(1) {
149+
panic!("seconds must be less then a day")
150+
};
147151
// build the time. this is only approximate, which is fine.
148152
let mut time = Tm {
149153
tm_sec: 0,
@@ -159,6 +163,6 @@ fn build_post_time(year: u32, month: u32, day: u32, seconds: u32) -> String {
159163
tm_utcoff: 0,
160164
tm_nsec: 0,
161165
};
162-
time = time + Duration::seconds(seconds as i64);
166+
time = time + seconds;
163167
time.rfc3339().to_string()
164168
}

0 commit comments

Comments
 (0)