main.go 658 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "fmt"
  4. "time"
  5. "bufio"
  6. "os"
  7. "strconv"
  8. )
  9. func main() {
  10. reader := bufio.NewReader(os.Stdin)
  11. // fmt.Print("Enter text: ")
  12. nano, _ := reader.ReadString('\n')
  13. /* tNow := time.Now()
  14. fmt.Println("time.Now() = ", tNow)
  15. tNano := tNow.UnixNano()
  16. fmt.Println("time.Now().UnixNano() = ", tNano)
  17. tNew := time.Unix(0, tNano)
  18. fmt.Println("tNew = ", tNew)
  19. */
  20. tNano, err := strconv.ParseInt(nano[:len(nano)-1], 10, 64)
  21. if err != nil {
  22. panic(err)
  23. }
  24. // fmt.Printf("Hello, %v with type %s!\n", i, reflect.TypeOf(i))
  25. nanotime := time.Unix(0, tNano)
  26. fmt.Println("nano from stdin = ", nanotime)
  27. // fmt.Println(tNow.Equal(tNew))
  28. }