Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a custom time zone

Tags:

timezone

r

Is it possible to create a custom time zone in R for handling datetime objects?

More specifically I am interested in dealing with POSIXct objects, and would like to create a time zone than corresponds to "US/Eastern" - 17 hours. Time zones with a similar offset do not follow the same daylight savings convention as the US.

The reason for using a time zone so defined comes from FX trading, for which 5 pm EST is a reasonable 'midnight'.

like image 376
Ryogi Avatar asked Dec 06 '25 16:12

Ryogi


1 Answers

When you are concerned about a specific ”midnight-like” time for each day, I assume that you want to obtain a date without time which switches over at that time. If that is your intention, then how about simply subtracting 17 hours (= 17*3600 seconds) from your vector of times, and taking the date of the resulting POSIXct value?

That would avoid complicated time zone maniplulations, which are usually not hanled by R itself but the underlying C libraray, as far as I know, so they might be difficult to achieve from within R. Instead, all computations would be performed in EST, and you'd still get a different switchover time than the local midnight.

like image 68
MvG Avatar answered Dec 08 '25 09:12

MvG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!