This repository was archived by the owner on Jun 21, 2020. It is now read-only.
File tree 2 files changed +8
-10
lines changed
2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ license = "MIT"
12
12
13
13
[dependencies ]
14
14
15
- time = " 0.1.12 "
15
+ time = " 0.1.25 "
16
16
17
17
[[bin ]]
18
18
Original file line number Diff line number Diff line change 1
1
extern crate time;
2
- use std:: time:: duration:: Duration ;
3
2
4
3
fn main ( ) {
5
4
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 ) ;
7
6
let seconds_of_first_day = now. to_timespec ( ) - time_since_first;
8
7
let first_of_the_month = time:: at_utc ( seconds_of_first_day) ;
8
+ let one_day = time:: Duration :: hours ( 24 ) ;
9
9
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
+ ) ;
12
14
println ! ( "Su Mo Tu We Th Fr Sa" ) ;
13
15
14
- let one_day = Duration :: hours ( 24 ) ;
15
-
16
16
let this_month = now. tm_mon ;
17
17
let mut current_day = first_of_the_month;
18
18
19
19
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 {
22
21
print ! ( " " ) ;
23
- count += 1 ;
24
22
}
25
23
}
26
24
while current_day. tm_mon == this_month {
You can’t perform that action at this time.
0 commit comments