|
|
package main |
|
|
|
import ( |
|
"fmt" |
|
"time" |
|
) |
|
|
|
func main() { |
|
p := fmt.Println |
|
|
|
now := time.Now() |
|
p(now) |
2020-10-21 16:54:00.904235185 +0000 UTC m=+0.000060923
|
|
|
then := time.Date( |
|
2009, 11, 17, 20, 34, 58, 651387237, time.UTC) |
|
p(then) |
2020-10-21 16:54:02.829757568 +0000 UTC m=+0.000048191
2009-11-17 20:34:58.651387237 +0000 UTC
|
|
|
p(then.Year()) |
2020-10-21 16:54:03.886828998 +0000 UTC m=+0.000116610
2009
|
p(then.Month()) |
2020-10-21 16:54:04.171776848 +0000 UTC m=+0.000050367
November
|
p(then.Day()) |
2020-10-21 16:54:04.401686494 +0000 UTC m=+0.000052769
17
|
p(then.Hour()) |
2020-10-21 16:54:04.642399259 +0000 UTC m=+0.000052578
20
|
p(then.Minute()) |
2020-10-21 16:54:04.871653014 +0000 UTC m=+0.000048731
34
|
p(then.Second()) |
2020-10-21 16:54:05.130703371 +0000 UTC m=+0.000050559
58
|
p(then.Nanosecond()) |
2020-10-21 16:54:05.51746681 +0000 UTC m=+0.000071720
651387237
|
p(then.Location()) |
2020-10-21 16:54:05.747987175 +0000 UTC m=+0.000111400
UTC
|
|
|
p(then.Weekday()) |
2020-10-21 16:54:06.421437974 +0000 UTC m=+0.000123589
Tuesday
|
|
|
p(then.Before(now)) |
2020-10-21 16:54:07.780311582 +0000 UTC m=+0.000048686
true
|
p(then.After(now)) |
2020-10-21 16:54:08.152713642 +0000 UTC m=+0.000054734
false
|
p(then.Equal(now)) |
2020-10-21 16:54:08.420382232 +0000 UTC m=+0.000057123
false
|
|
|
diff := now.Sub(then) |
|
p(diff) |
2020-10-21 16:54:09.601084795 +0000 UTC m=+0.000104919
95780h19m10.949697558s
|
|
|
p(diff.Hours()) |
2020-10-21 16:54:10.698911627 +0000 UTC m=+0.000061010
95780h19m12.04752439s
95780.32001320121
|
p(diff.Minutes()) |
2020-10-21 16:54:10.933625349 +0000 UTC m=+0.000051448
95780h19m12.282238112s
95780.32007839947
5.746819204703969e+06
|
p(diff.Seconds()) |
2020-10-21 16:54:11.303285301 +0000 UTC m=+0.000069789
95780h19m12.651898064s
95780.32018108279
5.746819210864968e+06
3.448091526518981e+08
|
p(diff.Nanoseconds()) |
2020-10-21 16:54:11.552612496 +0000 UTC m=+0.000050557
95780h19m12.901225259s
95780.32025034034
5.746819215020421e+06
3.4480915290122527e+08
344809152901225259
|
|
|
p(then.Add(diff)) |
2020-10-21 16:54:12.905584776 +0000 UTC m=+0.000111276
95780h19m14.254197539s
95780.32062616598
5.746819237569959e+06
3.4480915425419754e+08
344809154254197539
2020-10-21 16:54:12.905584776 +0000 UTC
|
p(then.Add(-diff)) |
2020-10-21 16:54:13.133868895 +0000 UTC m=+0.000049627
95780h19m14.482481658s
95780.32068957824
5.746819241374695e+06
3.4480915448248166e+08
344809154482481658
2020-10-21 16:54:13.133868895 +0000 UTC
1998-12-15 00:15:44.168905579 +0000 UTC
|
} |
2020-10-21 16:54:13.351398607 +0000 UTC m=+0.000052212
95780h19m14.70001137s
95780.32075000316
5.746819245000189e+06
3.448091547000114e+08
344809154700011370
2020-10-21 16:54:13.351398607 +0000 UTC
1998-12-15 00:15:43.951375867 +0000 UTC
|