Commit 986ce760 authored by Jean-Marie Lepioufle's avatar Jean-Marie Lepioufle
Browse files

add convert time zone

parent d33fc8f4
......@@ -10,11 +10,14 @@
#' luftlyr_df_data()
#' }
luftlyr_df_data <- function(x,res){
if (x$dateStructObj$COL_DATE) {
tmp <- df_data(x=x,ugly_df=res)
tmp <- df_data(x=x,ugly_df=res)
tmp$date <- timelyr::convertzone(ts=tmp$date,fromtzone="Europe/Oslo",totzone="UTC")
if (x$dateStructObj$COL_DATE) {
# ..
} else if (!x$dateStructObj$COL_DATE){
tmp <- timelyr::checkDate(df = df_data(x=x,ugly_df=res), timeObj=x$timeObj, missingValues = NA)
tmp <- timelyr::checkDate(df = tmp, timeObj=x$timeObj, missingValues = NA)
} else stop("COL_DATE in the right format")
......@@ -36,7 +39,8 @@ df_data <- function(x,ugly_df){
indice <- which( (ugly_df["ST_ID"] == x$stationObj$station_id[i_s]) & (ugly_df["CO_NAME"] == x$elementObj$element_id[i_e]))
}
stations_id <- x$stationObj$station_id[i_s]
tmp <- timelyr::checkDate(df=ugly_df[indice,],timeObj = x$timeObj, missingValues=NA,CONVERTZONE=FALSE,fromtzone="Europe/Oslo",totzone="UTC")[,"TE_VALUE"]
tmp <- timelyr::checkDate(df=ugly_df[indice,],timeObj = x$timeObj, missingValues=NA)[,"TE_VALUE"]
df <- tmp
if (length(x$stationObj$station_id)>2) {
......
......@@ -16,10 +16,15 @@ luftlyr_get_data <- function(x,username,password) {
tmp_st <- db$GetAQStations(stationIDs=x$stationObj$station_id,locationName=x$stationObj$locationName)
tmp_ts <- db$GetAQTimeseries(stationIDs=tmp_st$ST_ID,componentName=x$elementObj$element_id)
if (nrow(tmp_st)>0) {
# from utc to Europe/Oslo time zone
fromDateTime <- timelyr::convertzone(ts=x$timeObj$fromDateTime(),fromtzone="UTC",totzone="Europe/Oslo")
toDateTime <- timelyr::convertzone(ts=x$timeObj$toDateTime(),fromtzone="UTC",totzone="Europe/Oslo")
res <- db$GetAQData(stationIDs=tmp_st$ST_ID,
timeSeriesIDs=tmp_ts$TS_ID,
fromDateTime=as.character(x$timeObj$fromDateTime()),
toDateTime=as.character(x$timeObj$toDateTime()))
fromDateTime=as.character(fromDateTime),
toDateTime=as.character(toDateTime))
db$stop()
#Negative values
res[which(res$TE_VALUE<0),"TE_VALUE"]<-NA
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment