-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Datetime being parsed incorrectly #85
Comments
@dhersz can you share the code you are using for |
Also I suggest you use the
|
This is how I'm calling routes <- otp_plan(
otpcon,
from_place,
to_place,
fromID = from_place_ids,
toID = to_place_ids,
mode = c("WALK", "TRANSIT"),
date_time = as.POSIXct("13-05-2019 14:00:00", format = "%d-%m-%Y %H:%M:%S"),
maxWalkDistance = 1000,
numItineraries = 1,
ncores = n_cores,
distance_balance = TRUE,
get_geometry = FALSE
) EDIT: I think this has to do with my OS, I just tried with |
Did you specify a |
Doesn't sound like a problem with the package, as I can get the correct time on my computer. I'd try googling date/time problems in R |
Yes, Also tried with date_time <- lubridate::dmy_hms("13-05-2019 14:00:00", tz = "America/Sao_Paulo")
date <- format(date_time, "%m-%d-%Y", tz = "America/Sao_Paulo")
time <- tolower(format(date_time, "%I:%M%p", tz = "America/Sao_Paulo"))
date
#> [1] "05-13-2019"
time
#> [1] "02:00" |
From
|
Perhaps your local does not support the |
Changing system locale did the trick! Sys.setlocale("LC_TIME","en_US.UTF-8")
#> [1] "en_US.UTF-8"
date_time <- as.POSIXct("13-05-2019 14:00:00", format = "%d-%m-%Y %H:%M:%S")
timezone <- "America/Sao_Paulo"
time <- tolower(format(date_time, "%I:%M%p", tz = timezone))
time
#> [1] "02:00pm" Thanks for the heads-up @mem48! |
Describe the bug
I'm trying to calculate some routes departing from the following datetime:
format(as.POSIXct("13-05-2019 14:00:00", format = "%d-%m-%Y %H:%M:%S"
. However,otp_plan()
only returns itineraries that start very early in the morning. I tried playing a bit with thetimezone
argument but nothing worked. Then I checked how datetimes were parsed inside the function and realized that "14:00:00" is being parsed as "02:00", without am/pm indicator.To Reproduce
Expected behavior
time
should be02:00pm
System
The text was updated successfully, but these errors were encountered: