package common import ( "testing" "time" ) func TestTimeDay_GetMonthWithError(t *testing.T) { { day := TimeDay{Year: 2020, Month: 10} start, end, err := day.GetMonthWithError() if err != nil { t.Fatal(err) } t.Log(start.Format(FromatTime_V1)) t.Log(end.Format(FromatTime_V1)) // time_struct_test.go:13: 2020-10-01 00:00:00 // time_struct_test.go:14: 2020-11-01 00:00:00 } { day := TimeDay{Year: 2020, Month: 11} start, end, err := day.GetMonthWithError() if err != nil { t.Fatal(err) } t.Log(time.Now().Format(FromatTime_V1)) t.Log(start.Format(FromatTime_V1)) t.Log(end.Format(FromatTime_V1)) // time_struct_test.go:26: 2020-11-23 21:33:32 // time_struct_test.go:27: 2020-11-01 00:00:00 // time_struct_test.go:28: 2020-11-24 00:00:00 } } func TestTimeDay_GetDayWithError(t *testing.T) { { day := TimeDay{Year: 2020, Month: 10, Day: 1} start, end, err := day.GetDayWithError() if err != nil { t.Fatal(err) } t.Log(start.Format(FromatTime_V1)) t.Log(end.Format(FromatTime_V1)) // time_struct_test.go:42: 2020-10-01 00:00:00 // time_struct_test.go:43: 2020-10-01 23:59:59 } { t.Log(time.Now().Format(FromatTime_V1)) day := TimeDay{Year: 2020, Month: 12, Day: 31} start, end, err := day.GetMonthWithError() if err != nil { t.Fatal(err) } t.Log(start.Format(FromatTime_V1)) t.Log(end.Format(FromatTime_V1)) // time_struct_test.go:48: 2020-11-23 21:36:18 // time_struct_test.go:52: 查询时间大于当前系统时间 } }