Skip to content

Commit

Permalink
Merge branch 'f7-v8.3.2' of github.com:RinteRface/shinyMobile into f7…
Browse files Browse the repository at this point in the history
…-v8.3.2
  • Loading branch information
DivadNojnarg committed Mar 24, 2024
2 parents 2db4956 + 03a3416 commit f07841c
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 21 deletions.
3 changes: 2 additions & 1 deletion R/f7-inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ f7DatePicker <- function(inputId, label, value = NULL, multiple = FALSE, directi
toolbar = toolbar,
toolbarCloseText = toolbarCloseText,
header = header,
headerPlaceholder = headerPlaceholder
headerPlaceholder = headerPlaceholder,
...
))

buildPickerInput(
Expand Down
10 changes: 7 additions & 3 deletions R/onLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
} else {
f7DatePicker.date <- unlist(f7DatePicker.data)
if (is.numeric(f7DatePicker.date)) {
f7DatePicker.date <- as.POSIXct(f7DatePicker.date / 1000, tz = "UTC", origin = "1970-01-01")
as.POSIXct(f7DatePicker.date / 1000, tz = "UTC", origin = "1970-01-01")
} else {
f7DatePicker.date <- as.POSIXct(f7DatePicker.date, format = "%Y-%m-%dT%H:%M:%S", tz = "UTC")
# check if there's a time component
if (grepl("T", f7DatePicker.date)) {
as.POSIXct(f7DatePicker.date, format = "%Y-%m-%dT%H:%M:%S", tz = "UTC")
} else {
as.Date(f7DatePicker.date)
}
}
as.Date(f7DatePicker.date, tz = Sys.timezone())
}
}, force = TRUE)
}
11 changes: 6 additions & 5 deletions inst/examples/datepicker/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ app <- shinyApp(
),
f7DatePicker(
inputId = "picker",
label = "Choose a date",
value = Sys.Date() - 7,
label = "Choose a date and time",
value = Sys.time() - 3600*24,
openIn = "auto",
direction = "horizontal"
direction = "horizontal",
timePicker = TRUE
),
f7Block(verbatimTextOutput("pickerval"))
)
Expand All @@ -27,8 +28,8 @@ app <- shinyApp(
observeEvent(input$update, {
updateF7DatePicker(
inputId = "picker",
value = Sys.Date(),
multiple = TRUE
value = Sys.time(),
timePicker = TRUE
)
})

Expand Down
2 changes: 1 addition & 1 deletion inst/shinyMobile-1.0.1/dist/shinyMobile.min.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/shinyMobile-1.0.1/dist/shinyMobile.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/shinyMobile-1.0.1/dist/shinyMobile.min.js.map

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions srcjs/bindings/datePickerInputBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,22 @@ $.extend(f7DatePickerBinding, {
getValue: function(el) {
var val = this.instances[el.id].getValue();
var tmpDate;
var getTime = this.instances[el.id].hasTimePicker;
if (val.length == 1) {
var tmpDate = new Date(val);
tmpDate = Date.UTC(
tmpDate = new Date(val);
tmpDate = Date.UTC(
tmpDate.getFullYear(),
tmpDate.getMonth(),
tmpDate.getDate(),
tmpDate.getHours(),
tmpDate.getMinutes(),
tmpDate.getSeconds()
);
return new Date(tmpDate);
if (!getTime) {
return new Date(tmpDate).toISOString().slice(0, 10);
} else {
return new Date(tmpDate);
}
} else {
var dates = [];
for (var i = 0; i < val.length; i++) {
Expand All @@ -70,7 +75,11 @@ $.extend(f7DatePickerBinding, {
dates[i].getMinutes(),
dates[i].getSeconds()
);
dates[i] = new Date(dates[i]);
if (!getTime) {
dates[i] = new Date(dates[i]).toISOString().slice(0, 10);
} else {
dates[i] = new Date(dates[i]);
}
}
return dates;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"input": {
"picker": "2024-03-17"
"picker": "2024-03-23T21:04:00Z"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"input": {
"picker": "2024-03-17"
"picker": "2024-03-23T21:04:00Z"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"input": {
"picker": "2024-03-24"
"picker": "2024-03-24T00:00:00Z"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/testthat/test-f7DatePicker.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
library(shinytest2)
test_that("date picker works", {
skip_on_cran()
shiny_app_path <-
Expand Down

0 comments on commit f07841c

Please sign in to comment.