helm / helm/community

toDate produces wrong date?

Open
#334 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
495
Forks
210
PR merge metrics
No merged PRs in 30d

Description

I used the following code, to get the timestamp (seconds since the unix epoch) for a certain UTC date:

{{- $creationTimeAsDateObject := toDate "2006-01-02T15:04:05Z" "2024-01-30T13:06:59Z" }}
creationTimeAsDateObject: {{ $creationTimeAsDateObject }}
{{- $timestamp := $creationTimeAsDateObject | unixEpoch }}
timestamp: {{ $timestamp }}

It gave this output:

creationTimeAsDateObject: 2024-01-30 13:06:59 +0100 CET
timestamp: 1706616419

When I checked the timestamp using https://www.epochconverter.com/ it showed that:

"2024-01-30T13:06:59Z" is 1706620019
"2024-01-30 13:06:59 +0100 CET" is 1706616419

I.e. the "toDate" generated a date that was one hour off compared to the UTC date being passed in.
I.e. "2024-01-30T13:06:59Z" is NOT equal to "2024-01-30 13:06:59 +0100 CET"

I'm on Helm version:
version.BuildInfo{Version:"v3.13.1", GitCommit:"3547a4b5bf5edb5478ce352e18858d8a552a4110", GitTreeState:"clean", GoVersion:"go1.20.8"}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.