0 issues 1 contributor 4 branches 0 releases
Additions: 12 Deletions: 7 View patch
1 $if solaris {
2 return solaris_now()
3 }
4- $if linux || android {
5- return linux_now()
6- }
7+ return linux_now()
8+ /*
9 // defaults to most common feature, the microsecond precision is not available
10 // in this API call
11 t := C.time(0)
12 now := C.localtime(&t)
13 return convert_ctime(*now, 0)
14+ */
15 }
16
17 // utc returns the current UTC time.
18 $if solaris {
19 return solaris_utc()
20 }
21- $if linux || android {
22- return linux_utc()
23- }
24+ return linux_utc()
25+ /*
26 // defaults to most common feature, the microsecond precision is not available
27 // in this API call
28 t := C.time(0)
29 _ = C.time(&t)
30 return unix2(i64(t), 0)
31+ */
32 }
33
34 // new_time returns a time struct with calculated Unix time.
35
1 t1 := time.utc()
2 time.sleep(50 * time.millisecond)
3 t2 := time.utc()
4+ eprintln('t1: $t1')
5+ eprintln('t2: $t2')
6 ut1 := t1.unix_time()
7 ut2 := t2.unix_time()
8+ eprintln('ut1: $ut1')
9+ eprintln('ut2: $ut2')
10 assert ut2 - ut1 < 2
11 //
12 utm1 := t1.unix_time_milli()
13 utm2 := t2.unix_time_milli()
14+ eprintln('utm1: $utm1')
15+ eprintln('utm2: $utm2')
16 assert (utm1 - ut1 * 1000) < 1000
17 assert (utm2 - ut2 * 1000) < 1000
18 //
19- // println('utm1: $utm1 | utm2: $utm2')
20 assert utm2 - utm1 > 2
21 assert utm2 - utm1 < 999
22 }
23