Skip to content
This repository was archived by the owner on Jun 21, 2020. It is now read-only.

Commit 768f31e

Browse files
committed
Update for Rust 1.0
1 parent fec59e7 commit 768f31e

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "MIT"
1212

1313
[dependencies]
1414

15-
time = "0.1.12"
15+
time = "0.1.25"
1616

1717
[[bin]]
1818

src/cal.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
extern crate time;
2-
use std::time::duration::Duration;
32

43
fn main() {
54
let now = time::now_utc();
6-
let time_since_first = Duration::days((now.tm_mday - 1) as i64);
5+
let time_since_first = time::Duration::days((now.tm_mday - 1) as i64);
76
let seconds_of_first_day = now.to_timespec() - time_since_first;
87
let first_of_the_month = time::at_utc(seconds_of_first_day);
8+
let one_day = time::Duration::hours(24);
99

10-
print!("{:>11}", now.strftime("%B").ok().unwrap());
11-
println!(" {:<8}", now.strftime("%Y").ok().unwrap());
10+
print!("{:>11} {:<8}\n",
11+
now.strftime("%B").ok().unwrap().to_string(),
12+
now.strftime("%Y").ok().unwrap().to_string()
13+
);
1214
println!("Su Mo Tu We Th Fr Sa");
1315

14-
let one_day = Duration::hours(24);
15-
1616
let this_month = now.tm_mon;
1717
let mut current_day = first_of_the_month;
1818

1919
if current_day.tm_wday > 0 {
20-
let mut count = 0u32;
21-
while (count as i32) < current_day.tm_wday {
20+
for _ in 0..current_day.tm_wday {
2221
print!(" ");
23-
count += 1;
2422
}
2523
}
2624
while current_day.tm_mon == this_month {

0 commit comments

Comments
 (0)