mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
fill the first two digits for year based on the current year when importing a two-digit year
This commit is contained in:
@@ -383,8 +383,8 @@ func TestIIFTransactionDataFileParseImportedData_ParseShortMonthDayTwoDigitsYear
|
||||
"TRNS\t09/2/24\tTest Account\t123.45\n"+
|
||||
"SPL\t09/2/24\tTest Account2\t-123.45\n"+
|
||||
"ENDTRNS\t\t\t\n"+
|
||||
"TRNS\t9/3/24\tTest Account\t123.45\n"+
|
||||
"SPL\t9/3/24\tTest Account2\t-123.45\n"+
|
||||
"TRNS\t24/9/3\tTest Account\t123.45\n"+
|
||||
"SPL\t24/9/3\tTest Account2\t-123.45\n"+
|
||||
"ENDTRNS\t\t\t\n"), 0, nil, nil, nil, nil, nil)
|
||||
|
||||
assert.Nil(t, err)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package iif
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mayswind/ezbookkeeping/pkg/converters/datatable"
|
||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||
@@ -441,25 +439,13 @@ func (t *iifTransactionDataRowIterator) parseTransactionTime(dataset *iifTransac
|
||||
day := dateParts[1]
|
||||
year := dateParts[2]
|
||||
|
||||
if utils.IsValidYearMonthDayLongOrShortDateFormat(date) {
|
||||
if utils.IsValidYearMonthDayLongOrShortDateFormat(date) && !utils.IsValidMonthDayYearLongOrShortDateFormat(date) {
|
||||
year = dateParts[0]
|
||||
month = dateParts[1]
|
||||
day = dateParts[2]
|
||||
}
|
||||
|
||||
if len(year) == 2 {
|
||||
year = utils.IntToString(time.Now().Year()/100) + year
|
||||
}
|
||||
|
||||
if len(month) < 2 {
|
||||
month = "0" + month
|
||||
}
|
||||
|
||||
if len(day) < 2 {
|
||||
day = "0" + day
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s-%s-%s 00:00:00", year, month, day), nil
|
||||
return utils.FormatYearMonthDayToLongDateTime(year, month, day)
|
||||
}
|
||||
|
||||
func createNewIIfTransactionDataTable(ctx core.Context, accountDatasets []*iifAccountDataset, transactionDatasets []*iifTransactionDataset) (*iifTransactionDataTable, error) {
|
||||
|
||||
Reference in New Issue
Block a user