Skip to content

Commit 08926ec

Browse files
committed
[data] bug fix in datatable+excel time format
1 parent ecd91f6 commit 08926ec

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

R_scripts/functions/fun_data.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ unify.datetime = function(rawData){
7171
# Define columns with lower case names for further processing
7272
rawData$date = date_col[[1]]
7373
rawData$time = time_col[[1]]
74-
7574
datetimeformat = get.datetime.format(rawData[1,]$date, rawData[1,]$time)
7675
dateformat = get.date.format(rawData[1,]$date)
7776

7877
rawData = rawData %>%
7978
rowwise() %>%
8079
mutate(datetime = as.POSIXct(x = paste(date, time),
81-
format = datetimeformat),
80+
format = datetimeformat,
81+
tz = "GMT"),
8282
date = as.Date(date,
8383
format = dateformat))
8484
}

server.R

+11-4
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ shinyServer(function(input, output, session) {
432432
if ("dTime" %in% colnames(rawData)){
433433
rawDataTable = rawData %>%
434434
mutate(dTime = round(dTime, 2))
435+
rawDataTable = datatable(rawDataTable )%>%
436+
formatDate("datetime", "toLocaleString")
435437
} else {
436438
rawDataTable = tab.with.message(message.fail.upload)
437439
}
@@ -442,10 +444,15 @@ shinyServer(function(input, output, session) {
442444
#' (Data > Upload > Preview data)
443445
output$raw.long <- DT::renderDataTable(rownames = FALSE, {
444446
an.error.occured = FALSE
445-
tryCatch( { tab = deltaTempLongNoFilter() %>%
446-
mutate_if(is.numeric, round, 3) },
447-
error = function(e) {an.error.occured <<- TRUE})
448-
if (an.error.occured){
447+
tryCatch({
448+
tab = datatable(deltaTempLongNoFilter() %>%
449+
mutate_if(is.numeric, round, 3)) %>%
450+
formatDate("datetime", "toLocaleString")
451+
},
452+
error = function(e) {
453+
an.error.occured <<- TRUE
454+
})
455+
if (an.error.occured) {
449456
tab = tab.with.message(message.fail.upload)
450457
}
451458
return(tab)

0 commit comments

Comments
 (0)