加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
boundary_test.go 17.76 KB
一键复制 编辑 原始数据 按行查看 历史
gouguoyin 提交于 2021-08-16 09:42 . Optimize StartOfWeek and EndOfWeek
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
package carbon
import (
"strconv"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCarbon_StartOfCentury(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-01 00:00:00", "2000-01-01 00:00:00"},
{"2020-01-31 23:59:59", "2000-01-01 00:00:00"},
{"2020-02-01 13:14:15", "2000-01-01 00:00:00"},
{"2020-02-28", "2000-01-01 00:00:00"},
{"2020-02-29", "2000-01-01 00:00:00"},
}
for index, test := range tests {
c := Parse(test.input).StartOfCentury()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfCentury(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-01 00:00:00", "2099-12-31 23:59:59"},
{"2020-01-31 23:59:59", "2099-12-31 23:59:59"},
{"2020-02-01 13:14:15", "2099-12-31 23:59:59"},
{"2020-02-28", "2099-12-31 23:59:59"},
{"2020-02-29", "2099-12-31 23:59:59"},
}
for index, test := range tests {
c := Parse(test.input).EndOfCentury()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_StartOfDecade(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-31 23:59:59", "2020-01-01 00:00:00"},
{"2021-01-01 00:00:00", "2020-01-01 00:00:00"},
{"2029-01-31 23:59:59", "2020-01-01 00:00:00"},
{"2020-02-01 13:14:15", "2020-01-01 00:00:00"},
{"2020-02-28", "2020-01-01 00:00:00"},
{"2020-02-29", "2020-01-01 00:00:00"},
}
for index, test := range tests {
c := Parse(test.input).StartOfDecade()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfDecade(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-31 23:59:59", "2029-12-31 23:59:59"},
{"2021-01-01 00:00:00", "2029-12-31 23:59:59"},
{"2029-01-31 23:59:59", "2029-12-31 23:59:59"},
{"2020-02-01 13:14:15", "2029-12-31 23:59:59"},
{"2020-02-28", "2029-12-31 23:59:59"},
{"2020-02-29", "2029-12-31 23:59:59"},
}
for index, test := range tests {
c := Parse(test.input).EndOfDecade()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_StartOfYear(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-01 00:00:00", "2020-01-01 00:00:00"},
{"2020-01-31 23:59:59", "2020-01-01 00:00:00"},
{"2020-02-01 13:14:15", "2020-01-01 00:00:00"},
{"2020-02-28", "2020-01-01 00:00:00"},
{"2020-02-29", "2020-01-01 00:00:00"},
}
for index, test := range tests {
c := Parse(test.input).StartOfYear()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfYear(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-01 00:00:00", "2020-12-31 23:59:59"},
{"2020-01-31 23:59:59", "2020-12-31 23:59:59"},
{"2020-02-01 13:14:15", "2020-12-31 23:59:59"},
{"2020-02-28", "2020-12-31 23:59:59"},
{"2020-02-29", "2020-12-31 23:59:59"},
}
for index, test := range tests {
c := Parse(test.input).EndOfYear()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_StartOfQuarter(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-01 00:00:00"},
{"2020-02-15 00:00:00", "2020-01-01 00:00:00"},
{"2020-03-15 00:00:00", "2020-01-01 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-01 00:00:00"},
{"2020-05-15 23:59:59", "2020-04-01 00:00:00"},
{"2020-06-15 23:59:59", "2020-04-01 00:00:00"},
{"2020-07-15 23:59:59", "2020-07-01 00:00:00"},
{"2020-08-15 13:14:15", "2020-07-01 00:00:00"},
{"2020-09-15 13:14:15", "2020-07-01 00:00:00"},
{"2020-10-15", "2020-10-01 00:00:00"},
{"2020-11-15", "2020-10-01 00:00:00"},
{"2020-12-15", "2020-10-01 00:00:00"},
}
for index, test := range tests {
c := Parse(test.input).StartOfQuarter()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfQuarter(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-03-31 23:59:59"},
{"2020-02-15 00:00:00", "2020-03-31 23:59:59"},
{"2020-03-15 00:00:00", "2020-03-31 23:59:59"},
{"2020-04-15 23:59:59", "2020-06-30 23:59:59"},
{"2020-05-15 23:59:59", "2020-06-30 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-30 23:59:59"},
{"2020-07-15 23:59:59", "2020-09-30 23:59:59"},
{"2020-08-15 13:14:15", "2020-09-30 23:59:59"},
{"2020-09-15 13:14:15", "2020-09-30 23:59:59"},
{"2020-10-15", "2020-12-31 23:59:59"},
{"2020-11-15", "2020-12-31 23:59:59"},
{"2020-12-15", "2020-12-31 23:59:59"},
}
for index, test := range tests {
c := Parse(test.input).EndOfQuarter()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_StartOfMonth(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-01 00:00:00"},
{"2020-02-15 00:00:00", "2020-02-01 00:00:00"},
{"2020-03-15 00:00:00", "2020-03-01 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-01 00:00:00"},
{"2020-05-15 23:59:59", "2020-05-01 00:00:00"},
{"2020-06-15 23:59:59", "2020-06-01 00:00:00"},
{"2020-07-15 23:59:59", "2020-07-01 00:00:00"},
{"2020-08-15 13:14:15", "2020-08-01 00:00:00"},
{"2020-09-15 13:14:15", "2020-09-01 00:00:00"},
{"2020-10-15", "2020-10-01 00:00:00"},
{"2020-11-15", "2020-11-01 00:00:00"},
{"2020-12-15", "2020-12-01 00:00:00"},
}
for index, test := range tests {
c := Parse(test.input).StartOfMonth()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfMonth(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-31 23:59:59"},
{"2020-02-15 00:00:00", "2020-02-29 23:59:59"},
{"2020-03-15 00:00:00", "2020-03-31 23:59:59"},
{"2020-04-15 23:59:59", "2020-04-30 23:59:59"},
{"2020-05-15 23:59:59", "2020-05-31 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-30 23:59:59"},
{"2020-07-15 23:59:59", "2020-07-31 23:59:59"},
{"2020-08-15 13:14:15", "2020-08-31 23:59:59"},
{"2020-09-15 13:14:15", "2020-09-30 23:59:59"},
{"2020-10-15", "2020-10-31 23:59:59"},
{"2020-11-15", "2020-11-30 23:59:59"},
{"2020-12-15", "2020-12-31 23:59:59"},
}
for index, test := range tests {
c := Parse(test.input).EndOfMonth()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_StartOfWeek(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0000-00-00 00:00:00", ""},
{"", ""},
{"0000-00-00 00:00:00", ""},
{"2021-06-13", "2021-06-13 00:00:00"},
{"2021-06-14", "2021-06-13 00:00:00"},
{"2021-06-18", "2021-06-13 00:00:00"},
{"2021-06-19", "2021-06-13 00:00:00"},
{"2021-06-20", "2021-06-20 00:00:00"},
}
for index, test := range tests {
c := Parse(test.input).StartOfWeek()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfWeek(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0000-00-00 00:00:00", ""},
{"", ""},
{"0000-00-00 00:00:00", ""},
{"2021-06-13", "2021-06-19 23:59:59"},
{"2021-06-14", "2021-06-19 23:59:59"},
{"2021-06-18", "2021-06-19 23:59:59"},
{"2021-07-17", "2021-07-17 23:59:59"},
{"2021-07-18", "2021-07-24 23:59:59"},
}
for index, test := range tests {
c := Parse(test.input).EndOfWeek()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_StartOfDay(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:00:00"},
{"2020-02-15 00:00:00", "2020-02-15 00:00:00"},
{"2020-03-15 00:00:00", "2020-03-15 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-15 00:00:00"},
{"2020-05-15 23:59:59", "2020-05-15 00:00:00"},
{"2020-06-15 23:59:59", "2020-06-15 00:00:00"},
{"2020-07-15 23:59:59", "2020-07-15 00:00:00"},
{"2020-08-15 13:14:15", "2020-08-15 00:00:00"},
{"2020-09-15 13:14:15", "2020-09-15 00:00:00"},
{"2020-10-15", "2020-10-15 00:00:00"},
{"2020-11-15", "2020-11-15 00:00:00"},
{"2020-12-15", "2020-12-15 00:00:00"},
}
for index, test := range tests {
c := Parse(test.input).StartOfDay()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfDay(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 23:59:59"},
{"2020-02-15 00:00:00", "2020-02-15 23:59:59"},
{"2020-03-15 00:00:00", "2020-03-15 23:59:59"},
{"2020-04-15 23:59:59", "2020-04-15 23:59:59"},
{"2020-05-15 23:59:59", "2020-05-15 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-15 23:59:59"},
{"2020-07-15 23:59:59", "2020-07-15 23:59:59"},
{"2020-08-15 13:14:15", "2020-08-15 23:59:59"},
{"2020-09-15 13:14:15", "2020-09-15 23:59:59"},
{"2020-10-15", "2020-10-15 23:59:59"},
{"2020-11-15", "2020-11-15 23:59:59"},
{"2020-12-15", "2020-12-15 23:59:59"},
}
for index, test := range tests {
c := Parse(test.input).EndOfDay()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_StartOfHour(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:00:00"},
{"2020-02-15 00:00:00", "2020-02-15 00:00:00"},
{"2020-03-15 00:00:00", "2020-03-15 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-15 23:00:00"},
{"2020-05-15 23:59:59", "2020-05-15 23:00:00"},
{"2020-06-15 23:59:59", "2020-06-15 23:00:00"},
{"2020-07-15 23:59:59", "2020-07-15 23:00:00"},
{"2020-08-15 13:14:15", "2020-08-15 13:00:00"},
{"2020-09-15 13:14:15", "2020-09-15 13:00:00"},
{"2020-10-15", "2020-10-15 00:00:00"},
{"2020-11-15", "2020-11-15 00:00:00"},
{"2020-12-15", "2020-12-15 00:00:00"},
}
for index, test := range tests {
c := Parse(test.input).StartOfHour()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfHour(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:59:59"},
{"2020-02-15 00:00:00", "2020-02-15 00:59:59"},
{"2020-03-15 00:00:00", "2020-03-15 00:59:59"},
{"2020-04-15 23:59:59", "2020-04-15 23:59:59"},
{"2020-05-15 23:59:59", "2020-05-15 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-15 23:59:59"},
{"2020-07-15 23:59:59", "2020-07-15 23:59:59"},
{"2020-08-15 13:14:15", "2020-08-15 13:59:59"},
{"2020-09-15 13:14:15", "2020-09-15 13:59:59"},
{"2020-10-15", "2020-10-15 00:59:59"},
{"2020-11-15", "2020-11-15 00:59:59"},
{"2020-12-15", "2020-12-15 00:59:59"},
}
for index, test := range tests {
c := Parse(test.input).EndOfHour()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_StartOfMinute(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:00:00"},
{"2020-02-15 00:00:00", "2020-02-15 00:00:00"},
{"2020-03-15 00:00:00", "2020-03-15 00:00:00"},
{"2020-04-15 23:59:59", "2020-04-15 23:59:00"},
{"2020-05-15 23:59:59", "2020-05-15 23:59:00"},
{"2020-06-15 23:59:59", "2020-06-15 23:59:00"},
{"2020-07-15 23:59:59", "2020-07-15 23:59:00"},
{"2020-08-15 13:14:15", "2020-08-15 13:14:00"},
{"2020-09-15 13:14:15", "2020-09-15 13:14:00"},
{"2020-10-15", "2020-10-15 00:00:00"},
{"2020-11-15", "2020-11-15 00:00:00"},
{"2020-12-15", "2020-12-15 00:00:00"},
}
for index, test := range tests {
c := Parse(test.input).StartOfMinute()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfMinute(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00", "2020-01-15 00:00:59"},
{"2020-02-15 00:00:00", "2020-02-15 00:00:59"},
{"2020-03-15 00:00:00", "2020-03-15 00:00:59"},
{"2020-04-15 23:59:59", "2020-04-15 23:59:59"},
{"2020-05-15 23:59:59", "2020-05-15 23:59:59"},
{"2020-06-15 23:59:59", "2020-06-15 23:59:59"},
{"2020-07-15 23:59:59", "2020-07-15 23:59:59"},
{"2020-08-15 13:14:15", "2020-08-15 13:14:59"},
{"2020-09-15 13:14:15", "2020-09-15 13:14:59"},
{"2020-10-15", "2020-10-15 00:00:59"},
{"2020-11-15", "2020-11-15 00:00:59"},
{"2020-12-15", "2020-12-15 00:00:59"},
}
for index, test := range tests {
c := Parse(test.input).EndOfMinute()
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToDateTimeString(), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_StartOfSecond(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00.123", "2020-01-15 00:00:00.0"},
{"2020-02-15 00:00:00.123", "2020-02-15 00:00:00.0"},
{"2020-03-15 00:00:00.123", "2020-03-15 00:00:00.0"},
{"2020-04-15 23:59:59.123", "2020-04-15 23:59:59.0"},
{"2020-05-15 23:59:59.123", "2020-05-15 23:59:59.0"},
{"2020-06-15 23:59:59.123", "2020-06-15 23:59:59.0"},
{"2020-07-15 23:59:59.123", "2020-07-15 23:59:59.0"},
{"2020-08-15 13:14:15.123", "2020-08-15 13:14:15.0"},
{"2020-09-15 13:14:15.123", "2020-09-15 13:14:15.0"},
{"2020-10-15", "2020-10-15 00:00:00.0"},
{"2020-11-15", "2020-11-15 00:00:00.0"},
{"2020-12-15", "2020-12-15 00:00:00.0"},
}
for index, test := range tests {
c := Parse(test.input).StartOfSecond()
assert.Nil(c.Error)
assert.Equal(test.expected, c.Format("Y-m-d H:i:s.u"), "Current test index is "+strconv.Itoa(index))
}
}
func TestCarbon_EndOfSecond(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-15 00:00:00.123", "2020-01-15 00:00:00.999"},
{"2020-02-15 00:00:00.123", "2020-02-15 00:00:00.999"},
{"2020-03-15 00:00:00.123", "2020-03-15 00:00:00.999"},
{"2020-04-15 23:59:59.123", "2020-04-15 23:59:59.999"},
{"2020-05-15 23:59:59.123", "2020-05-15 23:59:59.999"},
{"2020-06-15 23:59:59.123", "2020-06-15 23:59:59.999"},
{"2020-07-15 23:59:59.123", "2020-07-15 23:59:59.999"},
{"2020-08-15 13:14:15.123", "2020-08-15 13:14:15.999"},
{"2020-09-15 13:14:15.123", "2020-09-15 13:14:15.999"},
{"2020-10-15", "2020-10-15 00:00:00.999"},
{"2020-11-15", "2020-11-15 00:00:00.999"},
{"2020-12-15", "2020-12-15 00:00:00.999"},
}
for index, test := range tests {
c := Parse(test.input).EndOfSecond()
assert.Nil(c.Error)
assert.Equal(test.expected, c.Format("Y-m-d H:i:s.u"), "Current test index is "+strconv.Itoa(index))
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化