fork 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, 1730089828465717800).In(jst))
  40. fmt.Println("sdsd", time.Unix(0, 1661180400000000000).In(jst))
  41. fmt.Println("bbbb", time.Unix(0, 1661180400000000000).In(jst))
  42. fmt.Println("cdcd", time.Unix(0, 1646060399999999999).In(jst))
  43. fmt.Println("vcvc", time.Unix(0, 1682299800000000000).In(jst))
  44. fmt.Println("2024/04/08 --- ", time.Date(2024, time.Month(4), 8, 0, 0, 0, 0, jst).UnixNano())
  45. fmt.Println("2024/04/10 --- ", time.Date(2024, time.Month(4), 10, 0, 0, 0, 0, jst).UnixNano())
  46. fmt.Println("2022-12-01-STATEMENT", time.Unix(0, 1669821042144608073).In(jst))
  47. fmt.Println("2022-12-01-STATUS", time.Unix(0, 1672499460554471700).In(jst))
  48. fmt.Println("2022-12-02-STATEMENT", time.Unix(0, 1672499466021016887).In(jst))
  49. fmt.Println("2022-12-02-STATUS", time.Unix(0, 1672499466021016887).In(jst))
  50.  
  51. t, _ := time.Parse("2006-01-02", "2022-04-01")
  52. fmt.Println(t.In(jst))
  53. fmt.Println("startDate 11/01", time.Date(2022, time.Month(11), 1, 0, 0, 0, 0, jst).UnixNano())
  54. fmt.Println("startDate 11/09", time.Date(2022, time.Month(11), 9, 0, 0, 0, 0, jst).UnixNano())
  55. fmt.Println("startDate 11/30", time.Date(2022, time.Month(11), 30, 0, 0, 0, 0, jst).UnixNano())
  56. fmt.Println("startDate 12/01", time.Date(2022, time.Month(12), 1, 0, 0, 0, 0, jst).UnixNano())
  57. fmt.Println("startDate 12/09", time.Date(2022, time.Month(12), 9, 0, 0, 0, 0, jst).UnixNano())
  58. fmt.Println("endDate 2023/08/24", time.Date(2023, time.Month(8), 24, 23, 59, 59, 999999999, jst).UnixNano())
  59. fmt.Println("endDate 2023/09/15(ms)", time.Date(2023, time.Month(9), 15, 23, 59, 59, 990000000, jst).UnixNano())
  60.  
  61. startOfApril := time.Date(2022, time.Month(4), 1, 0, 0, 0, 0, jst)
  62. endOfApril := time.Date(2022, time.Month(4), 30, 23, 59, 59, 999999999, jst)
  63.  
  64. fmt.Println("4/1", startOfApril)
  65. fmt.Println("4/30", endOfApril)
  66. fmt.Println(endOfApril.Day() - startOfApril.Day() + 1)
  67.  
  68. closingDate := time.Date(2022, time.Month(4), 20, 23, 59, 59, 999999999, jst)
  69.  
  70. fmt.Println(closingDate.AddDate(0, 0, -(31 - 1)))
  71.  
  72. fmt.Println(0 / 31)
  73. }
Success #stdin #stdout 0.01s 5284KB
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 1730090067374227355
2261 9214646399000000000
aaaa 2024-10-28 13:30:28.4657178 +0900 Asia/Tokyo
sdsd 2022-08-23 00:00:00 +0900 Asia/Tokyo
bbbb 2022-08-23 00:00:00 +0900 Asia/Tokyo
cdcd 2022-02-28 23:59:59.999999999 +0900 Asia/Tokyo
vcvc 2023-04-24 10:30:00 +0900 Asia/Tokyo
2024/04/08 ---  1712502000000000000
2024/04/10 ---  1712674800000000000
2022-12-01-STATEMENT 2022-12-01 00:10:42.144608073 +0900 Asia/Tokyo
2022-12-01-STATUS 2023-01-01 00:11:00.5544717 +0900 Asia/Tokyo
2022-12-02-STATEMENT 2023-01-01 00:11:06.021016887 +0900 Asia/Tokyo
2022-12-02-STATUS 2023-01-01 00:11:06.021016887 +0900 Asia/Tokyo
2022-04-01 09:00:00 +0900 Asia/Tokyo
startDate 11/01 1667228400000000000
startDate 11/09 1667919600000000000
startDate 11/30 1669734000000000000
startDate 12/01 1669820400000000000
startDate 12/09 1670511600000000000
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