FreeTube icon indicating copy to clipboard operation
FreeTube copied to clipboard

Convert "Permieres on" UTC time to local time

Open dennis1248 opened this issue 3 years ago • 17 comments

Currently "Premieres on" seems to be using UTC time instead of local time. I live in UTC+02:00 so a stream or video premier starting at 19:00:00 local time will be reported as starting on 17:00:00 UTC.

Could someone knowledgeable with the codebase confirm that this is indeed what FreeTube is doing? I am just guessing here as to what this behavior is caused by.

dennis1248 avatar Jun 18 '21 14:06 dennis1248

@PrestonN Any update on this issue? It seems to of been incorrectly labelled as an enhancement instead of a bug

Winterhuman avatar Apr 07 '22 13:04 Winterhuman

I use Freetube v0.16.0 on Arch Linux and currently use CEST time. I don't experience this issue, premiere time is reported as correct local time for me. @Winterhuman in the issue you opened you said you use FreeTube v0.13.2 Beta, have you tried any later versions of freetube?

While i say premiere time is reported correctly, it's displayed in the mm/dd/yyyy format with a 12 hour clock, I don't use this format at all. I thought this is might be related to some locale setting on my end but It's still formatted like that despite changing LC_TIME. Should I open an issue for this is, or is it something on my end.

Aiz0 avatar Jun 20 '22 21:06 Aiz0

Good question, I haven't tested this for a while and also haven't looked at any streams. I'll report back here if I can confirm or deny that this is still an issue

Winterhuman avatar Jun 30 '22 17:06 Winterhuman

@Aiz0 The date format is probably hard-coded, probably best to open an issue for supporting LC_TIME

Winterhuman avatar Jul 01 '22 19:07 Winterhuman

After setting ALL locale variables it seems to be using correct date format, yyyy-mm-dd with 24 hour clock.

Freetube uses the toLocaleString() to return the premier date as a string with locale settings.

Firefox seems to behave the same. Launching Firefox with LC_TIME=en_US.UTF-8 does not change date formatting. Launching it with LC_ALL=en_US.UTF-8 does.

It's very weird.

Aiz0 avatar Jul 01 '22 20:07 Aiz0

Yep, this is still an issue in FreeTube v0.16. timedatectl shows:

               Local time: Fri 2022-07-01 22:03:10 BST
           Universal time: Fri 2022-07-01 21:03:10 UTC
                 RTC time: Fri 2022-07-01 21:03:10
                Time zone: Europe/London (BST, +0100)

But, https://youtu.be/_BDClzHu-ho says it starts at 01/07/2022, 22:00:00, and it's 22:04 now; the video should say it starts at 23:00:00 and use BST time.

Winterhuman avatar Jul 01 '22 21:07 Winterhuman

Could this issue be related to Flathub/flatpak then? I've tested both the aur version and the portable x64 and both use correct time zone.

I've found this disscussion regarding another flathub app. https://github.com/flathub/com.slack.Slack/issues/43

From the discussion this was a temporary solution so try launching freetube like this If you still use flatpak flatpak override --user --env=TZ=Europe/London io.freetubeapp.FreeTube

Aiz0 avatar Jul 01 '22 21:07 Aiz0

After Installing FreeTube via flatpak I can confirm that premiere time will display in UTC. 2022-07-03_T21:44:48 Here you can see the difference between premiere time for flatpak install (left) and aur build(right) for a random upcoming livestream.

After running the override command once, flatpak freetube displayed the same premiere time as the aur build. flatpak override --user --env=TZ=Europe/Stockholm io.freetubeapp.FreeTube I only needed to run this once and it doesn't actually launch freetube. That was a misunderstanding on my part.

Now that the cause is known this issue should probably be renamed or moved to the flathub repository.

I also found out that the date format seems to depend on LC_MESSAGES for some reason.

Aiz0 avatar Jul 03 '22 20:07 Aiz0

For some reason, the FreeTube Flatpak manually sets TZ=UTC by default, which overrides the timezone of the system ~~(I think, I need to wait for a stream again to see if removing it has solved everything)~~

No other Flatpak I have installed sets TZ manually, I wonder why this is the case; perhaps it solves a bug from the past?

EDIT: Nevermind, the video release times are still one hour behind even after removing TZ=UTC.

Winterhuman avatar Jul 08 '22 12:07 Winterhuman

@efb4f5ff-1298-471a-8973-3d47447115dc Any chance you could comment on this?

Winterhuman avatar Jul 08 '22 12:07 Winterhuman

I looked into this again and removing --env=TZ=UTC seems to fix the issue for the latest freetube version on flathub. I get the correct timezone when i run Intl.DateTimeFormat().resolvedOptions().timeZone in console.

The reason it was added seems to be because of a crash if the time zone was unknown. https://github.com/flathub/io.freetubeapp.FreeTube/commit/279265af31ced8ccfe3e53a5b0e84a95c7011254 I tested it by changing to a unknown timezone--env=TZ=ETC/Unknown but I did not experience a crash.

running Intl.DateTimeFormat().resolvedOptions().timeZone returned Undefined and new Date().ToLocaleString() returned this '16/09/2022'

I suppose the workaround is no longer required in later versions of electron. I'll open a pull request on the flathub repository later.

@Winterhuman could you try removing TZ=UTC on v0.17.1 and see if you get the same results?

Aiz0 avatar Sep 16 '22 16:09 Aiz0

There's a build on the testing repository now: https://buildbot.flathub.org/#/builders/32/builds/110792 you can install it with this command

flatpak install --user https://dl.flathub.org/build-repo/108415/io.freetubeapp.FreeTube.flatpakref

Aiz0 avatar Sep 16 '22 17:09 Aiz0

I'll check next time I find a stream premiere

Winterhuman avatar Sep 17 '22 19:09 Winterhuman

Open this in browser and you should be able to find some upcoming live streams. https://www.youtube.com/live

Aiz0 avatar Sep 17 '22 19:09 Aiz0

Regardless of TZ=UTC or not, it's reporting the same time for me. However, the build you linked is changing the time to be an hour ahead of where it was which is correct

EDIT: Turns out I have to set TZ=UTC+1:00 before the time changes, removing the variable using Flatseal has no effect even after killing all Flatpak processes (for normal FreeTube)

Winterhuman avatar Sep 17 '22 20:09 Winterhuman

Just to be clear. Does the build I linked use the correct timezone without you having to make any modifications to the environment?

When you say you are removing TZ=UTC how exactly is that done? Are you using flatseal as you mentioned?

I have not tested this with flatseal but instead made a build without the line. here's how to do it if you wanna try.

git clone https://github.com/flathub/io.freetubeapp.FreeTube
cd io.freetubeapp.FreeTube

remove line 16 https://github.com/flathub/io.freetubeapp.FreeTube/blob/4dea01520f7d6b5a6b5c72707c39a1c6fd3ee07d/io.freetubeapp.FreeTube.yml#L16 and then build and install it with flatpak-builder

flatpak-builder build io.freetubeapp.FreeTube.yml  --install --force-clear

The build linked contains the same modifications and both work on my end.

Aiz0 avatar Sep 20 '22 17:09 Aiz0

Yes, your build does show the correct time

Winterhuman avatar Sep 20 '22 20:09 Winterhuman

@Aiz0 u have fixed this issue right?

@Aiz0 u have fixed this issue right?

As far as I know this should only be an issue on flatpak builds. This issue will be fixed when https://github.com/flathub/io.freetubeapp.FreeTube/pull/78 is merged.

Aiz0 avatar Oct 22 '22 15:10 Aiz0

Okay then ill close it because there is a separate repo for flatpak