Fix time acquisition by adding 'tz' arg
authorBenjamin Auder <benjamin.auder@somewhere>
Wed, 22 Mar 2017 14:32:12 +0000 (15:32 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Wed, 22 Mar 2017 14:32:12 +0000 (15:32 +0100)
pkg/R/getData.R

index a4e1e17..9ed0217 100644 (file)
@@ -49,14 +49,16 @@ getData = function(ts_data, exo_data, input_tz="GMT", date_format="%d/%m/%Y %H:%
                        read.csv(ts_data)
                else
                        ts_data
+       # Convert to the desired timezone (usually "GMT" or "Europe/Paris")
+       formatted_dates_POSIXlt = strptime(as.character(ts_df[,1]), date_format, tz=input_tz)
+       ts_df[,1] = format(as.POSIXct(formatted_dates_POSIXlt, tz=input_tz), tz=working_tz, usetz=TRUE)
+
        exo_df =
                if (is.character(exo_data))
                        read.csv(exo_data)
                else
                        exo_data
-       # Convert to the desired timezone (usually "GMT" or "Europe/Paris")
-       formatted_dates_POSIXlt = strptime(as.character(ts_df[,1]), date_format, tz=input_tz)
-       ts_df[,1] = format(as.POSIXct(formatted_dates_POSIXlt), tz=working_tz, usetz=TRUE)
+       # Times in exogenous variables file are ignored: no conversions required
 
        line = 1 #index in PM10 file (24 lines for 1 cell)
        nb_lines = nrow(ts_df)