Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time conversions are tied to timezone #5

Closed
troian opened this issue May 19, 2020 · 10 comments
Closed

Time conversions are tied to timezone #5

troian opened this issue May 19, 2020 · 10 comments

Comments

@troian
Copy link
Collaborator

troian commented May 19, 2020

IntToTimeTime for example returns local time. Does it make sense to turn into?

func IntToTimeTime(v int) time.Time {
	return time.Unix(int64(v), 0).UTC()
}
@RichardLindhout
Copy link
Member

I think we should output is as it is stored, so no UTC after getting it from database

@RichardLindhout
Copy link
Member

The int should be UNIX and unix should be already UTC since it's the definition of unix but it's always hard to work with timezones etc so not 100% sure about this.

@RichardLindhout
Copy link
Member

When storing it already converts to UTC: https://golang.org/pkg/time/#Time.Unix

@RichardLindhout
Copy link
Member

So I think you're code from pull request was fine 👍

@RichardLindhout
Copy link
Member

I think it's a hard problem maybe. In your API it would depend in some api's you wan't to return the local time and in some you don't want that.

@troian
Copy link
Collaborator Author

troian commented May 19, 2020

Thats quite strange though. We send UTC timestamp but IntToTimeTime converts it to local

@RichardLindhout
Copy link
Member

Ok hmm strange maybe set the TZ= environment variable. I always have difficulties with timezone with understanding them.

@RichardLindhout
Copy link
Member

I think setting TZ= is maybe a good idea.

@troian troian closed this as completed May 19, 2020
@RichardLindhout
Copy link
Member

If you use it in docker containers be aware that some containers don't include all timestamps. It did cost us quite some time to find that out back then :-D
download

@RichardLindhout
Copy link
Member

If you use alphine I think it was something like this.

FROM alpine:3.11

ARG TZ='Europe/Amsterdam'

ENV DEFAULT_TZ ${TZ}

RUN apk upgrade --update \
  && apk add -U tzdata \
  && cp /usr/share/zoneinfo/${DEFAULT_TZ} /etc/localtime \
  && apk del tzdata \
  && rm -rf \
  /var/cache/apk/*

CMD ["ls"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants