mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-04 08:40:28 +00:00
fix datetime bug
This commit is contained in:
parent
70a52b5bbd
commit
a803182fb3
2 changed files with 7 additions and 3 deletions
|
@ -50,9 +50,9 @@ func Test_CorrectDateParsing(t *testing.T) {
|
||||||
entity := newCsvRow(record)
|
entity := newCsvRow(record)
|
||||||
expected := expected[i-1]
|
expected := expected[i-1]
|
||||||
|
|
||||||
assert.Equal(t, expected, entity.Item.PurchaseTime, fmt.Sprintf("Failed on row %d", i))
|
assert.Equal(t, expected, entity.Item.PurchaseTime.Time(), fmt.Sprintf("Failed on row %d", i))
|
||||||
assert.Equal(t, expected, entity.Item.WarrantyExpires, fmt.Sprintf("Failed on row %d", i))
|
assert.Equal(t, expected, entity.Item.WarrantyExpires.Time(), fmt.Sprintf("Failed on row %d", i))
|
||||||
assert.Equal(t, expected, entity.Item.SoldTime, fmt.Sprintf("Failed on row %d", i))
|
assert.Equal(t, expected, entity.Item.SoldTime.Time(), fmt.Sprintf("Failed on row %d", i))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ func DateFromTime(t time.Time) Date {
|
||||||
//
|
//
|
||||||
// Errors are ignored and an empty Date is returned.
|
// Errors are ignored and an empty Date is returned.
|
||||||
func DateFromString(s string) Date {
|
func DateFromString(s string) Date {
|
||||||
|
if s == "" {
|
||||||
|
return Date{}
|
||||||
|
}
|
||||||
|
|
||||||
t, err := time.Parse("2006-01-02", s)
|
t, err := time.Parse("2006-01-02", s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: Remove - used by legacy importer
|
// TODO: Remove - used by legacy importer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue