marshmallow icon indicating copy to clipboard operation
marshmallow copied to clipboard

Saving timestamp as-is

Open amshim opened this issue 9 years ago • 3 comments

I am trying to use marshmallow.fields.DateTime and trying to save 2017-06-27T07:49:40-04:00 for example, but it keeps converting it to 2017-06-27T06:49:40+00:00

(I am in EDT)

I am not quite sure what the documentation means

Timezone-naive datetime objects are converted to UTC (+00:00) by Schema.dump. Schema.load returns datetime objects that are timezone-aware.

Is it converting to the system timezone? Because I don't want it to do that.

Is there a way I can force Marshmallow to leave the timestamp alone? Or do I have to revert to using fields.string instead of fields.datetime?

amshim avatar Jun 27 '17 11:06 amshim

Bump

amshim avatar Jul 21 '17 07:07 amshim

using marshmallow.fields.LocalDateTime ?

podhmo avatar Jul 21 '17 09:07 podhmo

Yes, LocalDateTime should meet your use case.

sloria avatar Jan 06 '18 15:01 sloria