I have two files and I need to change their last modification date: both should be midnight, one on 25th June and the other one on 25th November. Basically, this:
touch -cmt 201606242359.60 summer-file touch -cmt 201611242359.60 winter-file
Our server timezone is "Europe/Madrid", therefore we enjoy daylight saving time: we are in UTC+1 during the winter and UTC+2 during the summer. Which means that if I run the above commands now, they set the winter-file date correctly, but summer-file is one hour early: 24th June 23:00. If I ran them during the summer, I guess the summer-file would be the one OK and the other one would be 1:00 instead of 0:00.
After a bit of googling and a bit more of trial and error, I came up with this:
TZ=ZZZ-1 touch -cmt 201606242359.60 summer-file TZ=ZZZ-1 touch -cmt 201611242359.60 winter-file
Which correctly set the date of both files to 0:00 as intended. The problem is... I really don't know what I'm doing here. Changing the timezone to
ZZZ-1, because of... magic? Or... is it -1 because we are currently in UTC+1? Next March, when we switch to DST, our server will be 2 hours ahead of UTC instead of 1. Should I use then
ZZZ-2 instead, or will
ZZZ-1 still be fine? (I'd change the server date and just try myself, but I'm not allowed to do that, it would break a few things).
If I need
ZZZ-2 during the summer... is there another expression I can set
TZ= to instead, to make my touch work properly all around the year and for any target date? I've tried with
UTC0, none of them did work (they all set my summer-file to 1:00).
The commands are generated programmatically (in Siebel CRM), I guess I could check the current date and set
TZ=ZZZ-2 as needed (if needed), but I'd rather have only one expression.
Also, please notice our server is running Solaris 10, in case it makes any difference. It usually does...