I've noticed that value of an input_slider always return utc datetimes.
The input_slider has a property timezone, but apparently this is only for display reasons.
I would expect to have the slider return datetimes in the chosen timezone, or, in case of a None value for timezone, in the local timezone, but this is not the case.
A sample app :
from shiny import *
from datetime import datetime, timedelta
app_ui = ui.page_fluid(
ui.h2("Timerange Slider"),
ui.input_slider(id="in_timerange",
label="Time Range",
min=datetime.now() - timedelta(hours=24),
max=datetime.now(),
step=timedelta(hours=1),
time_format="%d-%H:00",
value=[datetime.now() - timedelta(hours=6), datetime.now() - timedelta(hours=4)],
width="1600px",
drag_range=True
),
ui.output_text_verbatim("out_timerange")
)
def server(input, output, session):
@output
@render.text
def out_timerange():
# add (datetime.now() - datetime.utcnow() to convert to local timezone
# timerange = [t + (datetime.now() - datetime.utcnow()) for t in input.in_timerange()]
timerange = input.in_timerange()
return timerange
app = App(app_ui, server)
def main():
run_app(app)
if __name__ == "__main__":
main()
Hello,
I've noticed that value of an input_slider always return utc datetimes. The input_slider has a property timezone, but apparently this is only for display reasons.
I would expect to have the slider return datetimes in the chosen timezone, or, in case of a None value for timezone, in the local timezone, but this is not the case.
A sample app :
Kind Regards
Bart