Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Date-manipulation/Go/date-manipulation.go
Normal file
31
Task/Date-manipulation/Go/date-manipulation.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
const taskDate = "March 7 2009 7:30pm EST"
|
||||
const taskFormat = "January 2 2006 3:04pm MST"
|
||||
|
||||
func main() {
|
||||
if etz, err := time.LoadLocation("US/Eastern"); err == nil {
|
||||
time.Local = etz
|
||||
}
|
||||
fmt.Println("Input: ", taskDate)
|
||||
t, err := time.Parse(taskFormat, taskDate)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
t = t.Add(12 * time.Hour)
|
||||
fmt.Println("+12 hrs: ", t)
|
||||
if _, offset := t.Zone(); offset == 0 {
|
||||
fmt.Println("No time zone info.")
|
||||
return
|
||||
}
|
||||
atz, err := time.LoadLocation("US/Arizona")
|
||||
if err == nil {
|
||||
fmt.Println("+12 hrs in Arizona:", t.In(atz))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue