golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.85k stars 17.52k forks source link

proposal: expose time.Location extend string for zone transitions #68367

Open jaesung9507 opened 2 months ago

jaesung9507 commented 2 months ago

Proposal Details

When zoneinfo is needed, it is parsed from the files in the /usr/share/zoneinfo/ directory. This implementation works only on Unix systems. I recently discovered that this value is stored in the extend field of the time.Location struct. I use this value to send to other devices.

I propose adding a getter function to retrieve this value:

func (l *Location) Extend() string

seankhliao commented 2 months ago

why is it necessary to expose this data? and from the looks of it, just extends is insufficient to describe all the time zone transitions correctly?

jaesung9507 commented 2 months ago

@seankhliao This value is used to transmit this value to IoT devices that do not have time zone information. Why not simply provide this value to those who need it?

seankhliao commented 2 months ago

I don't think that's sufficient information to capture zone transitions, exposing it doesn't seem appropriate if it's incomplete.

ianlancetaylor commented 2 months ago

I agree that just the extend string is not enough to handle timezone transitions. It only predicts future transitions, it doesn't cover past ones.

In any case this seems like something that belongs more in a third party library.

jaesung9507 commented 2 months ago

I understand that the extend string may not capture all zone transitions comprehensively. However, the ability to predict future transitions still holds significant value.

While it is true that the extend string focuses on future transitions and may not cover past ones, this limitation can be clearly documented.

shubhamgoyal1402 commented 1 week ago

To provide zone info to the device, do we have to display the current zone location ?

Sec32fun32 commented 1 week ago

Varsayılan bölge olarak