Here is a snippet of an R script I use to append newly downloaded hourly data to historical data in a csv file on disk
# get London and New York times and weekdays
london_time <- format( as.POSIXct( new_historical_data[ , 1 ] , tz = "UTC" ) , tz = "Europe/London" )
london_weekday <- as.POSIXlt( london_time )
london_weekday + 1 # +1 to match Octave's weekday representation
new_york_time <- format( as.POSIXct( new_historical_data[ , 1 ] , tz = "UTC" ) , tz = "America/New_York" )
new_york_weekday <- as.POSIXlt( new_york_time )
new_york_weekday + 1 # +1 to match Octave's weekday representation
# add London and New York times columns
new_historical_data <- cbind( new_historical_data[ , 1 ] , london_time , london_weekday , new_york_time , new_york_weekday , new_historical_data[ , 2 : 7 ] )
This changes the downloaded "new_historical_data" format from
UTC_date_time , open , high , ...
to
UTC_date_time , London_date_time , London_weekday_marker , New_York_date_time , New_York_weekday_marker , open , high , ...
format.
Because R references the installed time zone library on my system, the London and New York times are correctly adjusted for the appropriate daylight savings time