mirror of
https://github.com/araddon/dateparse.git
synced 2025-01-07 21:43:50 +08:00
add golang native format
This commit is contained in:
parent
abacbd8024
commit
33ad15a3c7
@ -105,6 +105,7 @@ iterRunes:
|
|||||||
// 2014-05-11 08:20:13,787
|
// 2014-05-11 08:20:13,787
|
||||||
// 2014-04-26 05:24:37 PM
|
// 2014-04-26 05:24:37 PM
|
||||||
// 2014-12-16 06:20:00 UTC
|
// 2014-12-16 06:20:00 UTC
|
||||||
|
// 2015-02-18 00:12:00 +0000 UTC
|
||||||
switch r {
|
switch r {
|
||||||
case 'A', 'P':
|
case 'A', 'P':
|
||||||
if len(datestr) == len("2014-04-26 03:24:37 PM") {
|
if len(datestr) == len("2014-04-26 03:24:37 PM") {
|
||||||
@ -373,6 +374,12 @@ iterRunes:
|
|||||||
} else {
|
} else {
|
||||||
return time.Time{}, err
|
return time.Time{}, err
|
||||||
}
|
}
|
||||||
|
} else if len(datestr) == len("2015-02-18 00:12:00 +0000 UTC") {
|
||||||
|
if t, err := time.Parse("2006-01-02 15:04:05 +0000 UTC", datestr); err == nil {
|
||||||
|
return t, nil
|
||||||
|
} else {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case ST_DIGITSLASH: // starts digit then slash 02/ (but nothing else)
|
case ST_DIGITSLASH: // starts digit then slash 02/ (but nothing else)
|
||||||
// 3/1/2014
|
// 3/1/2014
|
||||||
|
@ -84,11 +84,10 @@ func TestParse(t *testing.T) {
|
|||||||
//u.Debug(fmt.Sprintf("%v", ts.In(time.UTC)), " ---- ", ts)
|
//u.Debug(fmt.Sprintf("%v", ts.In(time.UTC)), " ---- ", ts)
|
||||||
assert.T(t, "2006-01-02 15:04:05 +0000 MST" == fmt.Sprintf("%v", ts))
|
assert.T(t, "2006-01-02 15:04:05 +0000 MST" == fmt.Sprintf("%v", ts))
|
||||||
|
|
||||||
// Wat? Go can't parse a date that it supplies a format for?
|
// Golang Native Format
|
||||||
// TODO: fixme
|
ts, err = ParseAny("2015-02-18 00:12:00 +0000 UTC")
|
||||||
//ts, err = ParseAny("Mon, 02 Jan 2006 15:04:05 -0700")
|
assert.Tf(t, err == nil, "%v", err)
|
||||||
//u.Debug(ts.In(time.UTC).Unix(), ts.In(time.UTC))
|
assert.T(t, "2015-02-18 00:12:00 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||||
//assert.T(t, "2006-01-02 15:04:05 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
|
||||||
|
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
// mm/dd/yyyy ?
|
// mm/dd/yyyy ?
|
||||||
|
Loading…
Reference in New Issue
Block a user