fork(1) download
  1. package main
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6.  
  7. func main(){
  8. a := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
  9. var b []int
  10. windowSize := 2
  11.  
  12. for i, e := 0, true; e; i++ {
  13. if windowSize < len(a) - windowSize * i {
  14. b = a[windowSize * i:windowSize * (i + 1)]
  15. } else {
  16. b = a[windowSize * i:]
  17. e = false
  18. }
  19.  
  20. fmt.Println("b:", b)
  21. }
  22.  
  23.  
  24. jst := time.FixedZone("Asia/Tokyo", 9*60*60)
  25.  
  26. fmt.Println(time.Date(2261, time.December, 30, 23, 59, 59, 0, time.UTC).UnixNano())
  27.  
  28.  
  29. fmt.Println("Format RFC3339Nano", time.Unix(0, 2057517719900000000).In(jst).Format(time.RFC3339Nano))
  30.  
  31. rfcTestTime, err := time.Parse(time.RFC3339Nano, "2022-09-19T17:10:33.403859986+09:00")
  32. fmt.Println("Parse RFC3339Nano 2022-09-19T17:10:33.403859986+09:00: ", rfcTestTime.UnixNano(), err)
  33.  
  34. rfcTestTimeEmpty, err := time.Parse(time.RFC3339Nano, "")
  35. fmt.Println("Parse RFC3339Nano empty: ", rfcTestTimeEmpty, err)
  36.  
  37. fmt.Println("now", time.Now().UnixNano())
  38. fmt.Println("2261", time.Date(2261, time.December, 31, 23, 59, 59, 0, time.UTC).UnixNano())
  39. fmt.Println("aaaa", time.Unix(0, 9214646399000000000).In(jst))
  40.  
  41. t, _ := time.Parse("2006-01-02", "2022-04-01")
  42. fmt.Println(t.In(jst))
  43. fmt.Println("startDate 2024/11/01", time.Date(2024, time.Month(11), 1, 0, 0, 0, 0, jst).UnixNano())
  44. fmt.Println("endDate 2023/08/24", time.Date(2023, time.Month(8), 24, 23, 59, 59, 999999999, jst).UnixNano())
  45. fmt.Println("endDate 2023/09/15(ms)", time.Date(2023, time.Month(9), 15, 23, 59, 59, 990000000, jst).UnixNano())
  46.  
  47. startOfApril := time.Date(2022, time.Month(4), 1, 0, 0, 0, 0, jst)
  48. endOfApril := time.Date(2022, time.Month(4), 30, 23, 59, 59, 999999999, jst)
  49.  
  50. fmt.Println("4/1", startOfApril)
  51. fmt.Println("4/30", endOfApril)
  52. fmt.Println(endOfApril.Day() - startOfApril.Day() + 1)
  53.  
  54. closingDate := time.Date(2022, time.Month(4), 20, 23, 59, 59, 999999999, jst)
  55.  
  56. fmt.Println(closingDate.AddDate(0, 0, -(31 - 1)))
  57.  
  58. fmt.Println(0 / 31)
  59. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
b: [0 1]
b: [2 3]
b: [4 5]
b: [6 7]
b: [8 9]
b: [10]
9214559999000000000
Format RFC3339Nano 2035-03-15T05:41:59.9+09:00
Parse RFC3339Nano 2022-09-19T17:10:33.403859986+09:00:  1663575033403859986 <nil>
Parse RFC3339Nano empty:  0001-01-01 00:00:00 +0000 UTC parsing time "" as "2006-01-02T15:04:05.999999999Z07:00": cannot parse "" as "2006"
now 1730261137383354511
2261 9214646399000000000
aaaa 2262-01-01 08:59:59 +0900 Asia/Tokyo
2022-04-01 09:00:00 +0900 Asia/Tokyo
startDate 2024/11/01 1730386800000000000
endDate 2023/08/24 1692889199999999999
endDate 2023/09/15(ms) 1694789999990000000
4/1 2022-04-01 00:00:00 +0900 Asia/Tokyo
4/30 2022-04-30 23:59:59.999999999 +0900 Asia/Tokyo
30
2022-03-21 23:59:59.999999999 +0900 Asia/Tokyo
0