libfaketime icon indicating copy to clipboard operation
libfaketime copied to clipboard

Faketime issue with date timezone conversion

Open kotsis opened this issue 2 years ago • 1 comments

Hello everyone, I got a weird case of Faketime affecting/interfering with a simple date conversion, which I wouldn't expect, since it is a simple date conversion of a specific timestamp. It also seems to only happen in RockyLinux8 distro.

e.g. in Centos7:

[root@vagrant vagrant]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

[root@vagrant vagrant]# date -d @1396627200
Sat Apr  5 00:00:00 +08 2014

#utc date -08:00
[root@vagrant vagrant]# date -u -d @1396627200 +%Y-%m-%dT%H:%M:00Z
2014-04-04T16:00:00Z

#utf date -08:00 with faketime matches, all good
[root@vagrant vagrant]# LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 date -u -d @1396627200 +%Y-%m-%dT%H:%M:00Z
2014-04-04T16:00:00Z

But in RockyLinux8 distro:

[root@vagrant vagrant]# cat /etc/centos-release
Rocky Linux release 8.9 (Green Obsidian)

[root@vagrant vagrant]# date -d @1396627200
Sat Apr  5 00:00:00 +08 2014

#utc date -08:00
[root@vagrant vagrant]# date -u -d @1396627200 +%Y-%m-%dT%H:%M:00Z
2014-04-04T16:00:00Z

#utf date -08:00 with faketime is wrong now!
[root@vagrant vagrant]# LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 date -u -d @1396627200 +%Y-%m-%dT%H:%M:00Z
2014-04-05T00:00:00Z

Not sure why this happens only in RockyLinux8 , last case.

PS: I use LD_PRELOAD for a bash script, which contains above date conversions, and the bug in RockyLinux8 boils down to above case.

kotsis avatar Mar 08 '24 09:03 kotsis

Could you provide code that prints #utf date -08:00 with faketime matches, all good and #utf date -08:00 with faketime is wrong now!

PiotrBzdrega avatar May 16 '25 09:05 PiotrBzdrega