forked from keshavsingh4522/hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeconversion.py
32 lines (25 loc) · 971 Bytes
/
timeconversion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/py
from datetime import datetime
def convertToEuTime(us_time):
return datetime.strptime(us_time, '%I:%M:%S%p').strftime('%H:%M:%S')
if __name__ == '__main__':
us_time = raw_input()
print convertToEuTime(us_time)
use std::io;
fn main() {
let mut line = String::new();
io::stdin().read_line(&mut line).ok().expect("Failed to read line");
let a: String = line.chars().skip(0).take(2).collect();
let b: String = line.chars().skip(3).take(2).collect();
let c: String = line.chars().skip(6).take(2).collect();
let d: String = line.chars().skip(8).take(2).collect();
let a = a.trim().parse::<u32>().unwrap();
let b = b.trim().parse::<u32>().unwrap();
let c = c.trim().parse::<u32>().unwrap();
let a = (a % 12) + match d.as_ref() {
"AM" => 0,
"PM" => 12,
_ => panic!("Unknown date type"),
};
println!("{:02}:{:02}:{:02}", a, b, c);
}