3.5 C
New York
Wednesday, December 25, 2024

Methods to set a customized time zone offset in Sonoma?


I wish to set my clock 5 minutes quicker than the true time. A technique to do that is to disable auto-set time and set the time manually.

However this fashion the time is flawed doing date +%s will give incorrect timestamps. Moreover, some web sites and apps don’t work correctly because of this, resembling TOTP.

So I attempted setting a customized timezone offset with zic from https://github.com/eggert/tz.

$ echo "Zone    Asia/Kolkata+05    5:35    -    IST+05" | zic -b fats -d . -

This gave me a legitimate TZinf file.

$ file Asia/Kolkata+05
Asia/Kolkata+05: timezone information (fats), model 2, no gmt time flags, no std time flags, no leap seconds, no transition instances, 1 native time kind, 7 abbreviation chars

I attempted setting the timezone with systemsetup however it would not permit this timezone. Chatgpt suggests disabling SIP and shifting the file, however I am unable to do this as a result of I am on a piece laptop computer.

$ sudo systemsetup -settimezone ~/Asia/Kolkata+05
/Customers/karan/Asia/Kolkata+05 isn't a legitimate timezone. The command 'listtimezones' will present a listing of legitimate time zones.

$ sudo cp Asia/Kolkata+05 /usr/share/zoneinfo/Asia/
cp: /usr/share/zoneinfo/Asia/Kolkata+05: Operation not permitted

Exporting the TZ variable to this timezone works with the date and gdate utilities, however I wish to see the system time with this offset.

$ export TZ="/Customers/karan/Asia/Kolkata+05"
$ date
Wed Dec 25 03:42:09 IST+05 2024
$ gdate
Wed Dec 25 03:42:15 IST+05 2024

I additionally tried setting a symlink to native time, however it resets the timezone to Pacific time.

sudo ln -sf ~/Asia/Kolkata+05 /and many others/localtime

Related Articles

Latest Articles