fill the first two digits for year based on the current year when importing a two-digit year

This commit is contained in:
MaysWind
2025-06-19 22:36:40 +08:00
parent 787eaad352
commit 5dc0e925c1
6 changed files with 68 additions and 21 deletions
+17
View File
@@ -46,6 +46,23 @@ func TestFormatUnixTimeToLongDateTime(t *testing.T) {
assert.Equal(t, expectedValue, actualValue)
}
func TestFormatYearMonthDayToLongDateTime(t *testing.T) {
expectedValue := "2025-06-01 00:00:00"
actualValue, err := FormatYearMonthDayToLongDateTime("25", "06", "01")
assert.Nil(t, err)
assert.Equal(t, expectedValue, actualValue)
expectedValue = "2025-06-01 00:00:00"
actualValue, err = FormatYearMonthDayToLongDateTime("25", "6", "1")
assert.Nil(t, err)
assert.Equal(t, expectedValue, actualValue)
expectedValue = "1990-06-01 00:00:00"
actualValue, err = FormatYearMonthDayToLongDateTime("90", "06", "01")
assert.Nil(t, err)
assert.Equal(t, expectedValue, actualValue)
}
func TestFormatUnixTimeToLongDateTimeWithoutSecond(t *testing.T) {
unixTime := int64(1617228083)
utcTimezone := time.FixedZone("Test Timezone", 0) // UTC