GithubHelp home page GithubHelp logo

Insert Local Date, Get UTC about go-hdb HOT 4 CLOSED

sap avatar sap commented on July 2, 2024
Insert Local Date, Get UTC

from go-hdb.

Comments (4)

stfnmllr avatar stfnmllr commented on July 2, 2024

The go-hdb driver does use a normalized (UTC) date / time by intention.

Just imagine that your application is used to read and write data in different time zones. Without additional information from which time zone the timestamp was created the information is unusable.

With UTC timestamps are stored time zone independently and the local date / time can be ‘calculated’ after reading from database.

Hope that helps

from go-hdb.

iambudi avatar iambudi commented on July 2, 2024

With UTC timestamps are stored time zone independently and the local date / time can be ‘calculated’ after reading from database.

This should become developer decision to store in UTC or Local time rather than forced by sql driver. Anyone can have different case.

I guess that's why HANADB itself provide two function CURRENT_TIMESTAMP and CURRENT_UTCTIMESTAMP.

Thanks.

from go-hdb.

stfnmllr avatar stfnmllr commented on July 2, 2024

This should become developer decision to store in UTC or Local time rather than forced by sql Driver

from go-hdb.

stfnmllr avatar stfnmllr commented on July 2, 2024

This should become developer decision to store in UTC or Local time rather than forced by sql Driver
Which is unfortunately not possible using https://golang.org/pkg/time/#Time as canonical go representation of db date / time fields

type Time struct {
	// ...
	wall uint64
	ext  int64
	// loc specifies the Location that should be used to
	// determine the minute, hour, month, day, and year
	// that correspond to this Time.
	// The nil location means UTC.
	// All UTC times are represented with loc==nil, never loc==&utcLoc.
	loc *Location
}

Like you can see, location information is part of time.Time. The driver could whether

  1. ignore location information (which is wrong)
  2. or transform time to local time (which leads to information loss, as the location is not stored in db)
  3. or using a normalized form like UTC to store data / time in db

from go-hdb.

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.