package main
import (
"fmt"
"time"
)
func main(){
a := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
var b []int
windowSize := 2
for i, e := 0, true; e; i++ {
if windowSize < len(a) - windowSize * i {
b = a[windowSize * i:windowSize * (i + 1)]
} else {
b = a[windowSize * i:]
e = false
}
fmt.Println("b:", b)
}
jst
:= time.
FixedZone("Asia/Tokyo", 9*60*60)
fmt.
Println(time.
Date(2261, time.
December, 30, 23, 59, 59, 0, time.
UTC).
UnixNano())
fmt.
Println("Format RFC3339Nano", time.
Unix(0, 2057517719900000000).
In(jst
).
Format(time.
RFC3339Nano))
rfcTestTime
, err
:= time.
Parse(time.
RFC3339Nano, "2022-09-19T17:10:33.403859986+09:00") fmt.Println("Parse RFC3339Nano 2022-09-19T17:10:33.403859986+09:00: ", rfcTestTime.UnixNano(), err)
rfcTestTimeEmpty
, err
:= time.
Parse(time.
RFC3339Nano, "") fmt.Println("Parse RFC3339Nano empty: ", rfcTestTimeEmpty, err)
fmt.
Println("now", time.
Now().
UnixNano()) fmt.
Println("2261", time.
Date(2261, time.
December, 31, 23, 59, 59, 0, time.
UTC).
UnixNano()) fmt.
Println("aaaa", time.
Unix(0, 9214646399000000000).
In(jst
))
t
, _
:= time.
Parse("2006-01-02", "2022-04-01") fmt.Println(t.In(jst))
fmt.
Println("startDate 2024/11/01", time.
Date(2024, time.
Month(11), 1, 0, 0, 0, 0, jst
).
UnixNano()) fmt.
Println("endDate 2023/08/24", time.
Date(2023, time.
Month(8), 24, 23, 59, 59, 999999999, jst
).
UnixNano()) fmt.
Println("endDate 2023/09/15(ms)", time.
Date(2023, time.
Month(9), 15, 23, 59, 59, 990000000, jst
).
UnixNano())
startOfApril
:= time.
Date(2022, time.
Month(4), 1, 0, 0, 0, 0, jst
) endOfApril
:= time.
Date(2022, time.
Month(4), 30, 23, 59, 59, 999999999, jst
)
fmt.Println("4/1", startOfApril)
fmt.Println("4/30", endOfApril)
fmt.Println(endOfApril.Day() - startOfApril.Day() + 1)
closingDate
:= time.
Date(2022, time.
Month(4), 20, 23, 59, 59, 999999999, jst
)
fmt.Println(closingDate.AddDate(0, 0, -(31 - 1)))
fmt.Println(0 / 31)
}
cGFja2FnZSBtYWluCmltcG9ydCAoCgkiZm10IgoJInRpbWUiCikKCmZ1bmMgbWFpbigpewoJYSA6PSBbXWludHswLCAxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5LCAxMH0KCXZhciBiIFtdaW50Cgl3aW5kb3dTaXplIDo9IDIKCQoJZm9yIGksIGUgOj0gMCwgdHJ1ZTsgZTsgaSsrIHsKCQlpZiB3aW5kb3dTaXplIDwgbGVuKGEpIC0gd2luZG93U2l6ZSAqIGkgewoJCQliID0gYVt3aW5kb3dTaXplICogaTp3aW5kb3dTaXplICogKGkgKyAxKV0KCQl9IGVsc2UgewoJCQliID0gYVt3aW5kb3dTaXplICogaTpdCgkJCWUgPSBmYWxzZQoJCX0KCQkKCQlmbXQuUHJpbnRsbigiYjoiLCBiKQoJfQoJCgkKCWpzdCA6PSB0aW1lLkZpeGVkWm9uZSgiQXNpYS9Ub2t5byIsIDkqNjAqNjApCgkKCWZtdC5QcmludGxuKHRpbWUuRGF0ZSgyMjYxLCB0aW1lLkRlY2VtYmVyLCAzMCwgMjMsIDU5LCA1OSwgMCwgdGltZS5VVEMpLlVuaXhOYW5vKCkpCgoKICAgIGZtdC5QcmludGxuKCJGb3JtYXQgUkZDMzMzOU5hbm8iLCB0aW1lLlVuaXgoMCwgMjA1NzUxNzcxOTkwMDAwMDAwMCkuSW4oanN0KS5Gb3JtYXQodGltZS5SRkMzMzM5TmFubykpCgogICAgcmZjVGVzdFRpbWUsIGVyciA6PSB0aW1lLlBhcnNlKHRpbWUuUkZDMzMzOU5hbm8sICIyMDIyLTA5LTE5VDE3OjEwOjMzLjQwMzg1OTk4NiswOTowMCIpCiAgICBmbXQuUHJpbnRsbigiUGFyc2UgUkZDMzMzOU5hbm8gMjAyMi0wOS0xOVQxNzoxMDozMy40MDM4N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