Comments (2)
This issue persists in the latest version as well, in now.Parse().
I can 100% reproduce it with the following code on a fresh project created in GoLand.
testTime, err := now.Parse("2021-07-20T00:59:10Z")
if err != nil {
fmt.Println(err)
}
fmt.Println(testTime)
The result is the same as the OP. Current hour is used instead (the code was executed at 8:00 local time for example).
2021-07-20 08:59:10 +0000 UTC
Additional reproducible test cases:
"2021-07-20T00:00:00Z" -> "2021-07-20 00:00:00 +0000 UTC" (PASS)
"2021-07-20T00:00:10Z" -> "2021-07-20 09:22:10 +0000 UTC" (FAIL, current hour and current minute used instead of 00)
"2021-07-20T00:01:00Z" -> "2021-07-20 09:01:00 +0000 UTC" (FAIL, current hour used instead of 00)
"2021-07-20T06:00:00Z" -> "2021-07-20 06:00:00 +0000 UTC" (PASS)
from now.
An update on the matter.
It seems the fix above only addressed the error for format "2006-01-02 15:04:05", but not "2006-01-02T15:04:05Z" (ISO 8601). The following test case would fail if I change "2002-10-12 00:14:56" to "2002-10-12T00:14:56Z". The result has the hour specified in n
instead of 00.
now_test.go:32: Failed Parse 2002-10-12T00:14:56Z: actual: 2002-10-12 17:14:56, expected: 2002-10-12 00:14:56
from now.
Related Issues (20)
- License
- Make FirstDayMonday a variable on now.Now struct or a parameter to BeginningOfWeek HOT 1
- Unable to parse time without day HOT 1
- Milliseconds are not parsed correctly
- Alternative API?
- Broken when clocks go back HOT 2
- WeekStartDay as an attribute of Now type HOT 2
- 可以考虑内置支持下这些格式吗?
- Cant find variable now HOT 1
- Parse day of the week
- please add mysql datetime layout HOT 1
- Beginning of Month error HOT 1
- Current quarter HOT 1
- don't allocate config inside With() HOT 1
- Make easier to test with time.Now as a config HOT 2
- Serious error with format "2006-01-02T15:04:05Z" (also see #22) HOT 1
- How about add a maxTime and a minTime const
- How do get the previous month's time? HOT 1
- Recommend a better golang package for datetime
- Rename License to LICENSE HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from now.