Code Monkey home page Code Monkey logo

Comments (2)

lss4 avatar lss4 commented on August 17, 2024

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.

lss4 avatar lss4 commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.