I have a file of datetime strings which I read in, with the added information, if it is daylight saving time or not, so for example the format:
"2024-10-27 02:30:00 CEST"
But this time datetime value can also exist as
"2024-10-27 02:30:00 CET"
depending on the fact if the time was measured before or after the time switch.
If I have a string like this, I want to parse it into a POSIXct object, but so that it keeps the info of CEST or CET. If I parse this string into POSIXct, the result is
> as.POSIXct("2024-10-27 02:30 CEST", tz="Europe/Berlin")
[1] "2024-10-27 02:30:00 CEST"
> as.POSIXct("2024-10-27 02:30 CET", tz="Europe/Berlin")
[1] "2024-10-27 02:30:00 CEST"
This means I lose the information about CET.
Is there a possibility to parse the string into POSIXct and keep the information, which also works for different timezones?
The only possibility I found so far is using
> as.POSIXct("2024-10-27 02:30 CET", tz="Europe/Berlin")+60*60
[1] "2024-10-27 02:30:00 CET"
to switch the time back again to CET, but this solution is hardly generalizable for all timezones, since I would have to know, when the switch happends for each timezone, and which substring (e.g. CEST and CET) stands for before and after the time switch and then to decide if I want to add the hour or not.
Would greatly appreaciate any help.