Face value date time on DatePicker to server

Hi there,

If you pass a timezone-unaware datetime between client and server, it will be made timezone-aware (in the timezone of the sending code) before transmission. We do this because an unaware timestamp is probably not what the user wants.

As you do want to send it over unaware, you have two options:

  1. Format it to a string with strftime, send that, then strptime on the other end. This matches the model you want - you don’t want to communicate “the instant in time chosen by the user”; you want “the text displayed on the face of the time picker”.

  2. Send the timestamp, then force it back to being naive again on the other end: Eg:

# On the client
anvil.server.call('foo', self.datepicker_1.datetime) 
# On the server
@anvil.server.callable
def foo(dt):
  dt = dt.replace(tzinfo=None)
  # dt's hour/minute/etc are unchanged, but it's now
  # naive again