question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fields.DateTime - load/dump to timestamp

See original GitHub issue

I’m currently using this code to parse/dump timestamp, but I believe this should be in standard library. Should I create pull request, or have I missed another way to work with datetime/timestamp format?

class DateTime(ma.fields.DateTime):
    """
    Class extends marshmallow standart DateTime with "timestamp" format.
    """

    DATEFORMAT_SERIALIZATION_FUNCS = \
        ma.fields.DateTime.DATEFORMAT_SERIALIZATION_FUNCS.copy()
    DATEFORMAT_DESERIALIZATION_FUNCS = \
        ma.fields.DateTime.DATEFORMAT_DESERIALIZATION_FUNCS.copy()

    DATEFORMAT_SERIALIZATION_FUNCS['timestamp'] = lambda x: x.timestamp()
    DATEFORMAT_DESERIALIZATION_FUNCS['timestamp'] = datetime.fromtimestamp

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:17
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

25reactions
disconnect3dcommented, Aug 24, 2017

Bump, this would be nice to have 👍

24reactions
james-willcoxcommented, Sep 1, 2020

Bump, would love to have this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert date and time fields to timestamp - Stack Overflow
I am working with a SQL Server table that shows date modified and time modified in two separate columns. I need to combine...
Read more >
Changing the field date type from 'datetime' to 'unix timestamp ...
I am investigating how could I convert the date format in the 4 database tables: field_data_field_article_publication_date from the actual ...
Read more >
11.2.2 The DATE, DATETIME, and TIMESTAMP Types
MySQL recognizes DATE , DATETIME , and TIMESTAMP values in several formats, ... A DATETIME or TIMESTAMP value can include a trailing fractional...
Read more >
Data.DB.TSQLTimeStampField - Embarcadero DocWiki
TSQLTimeStampField represents a date-time field in a DBExpress dataset. TSQLTimeStampField encapsulates the fundamental behavior common to Date-time fields.
Read more >
MySQL Date Format And Timestamp Functions With Examples
MySQL Date And Time Functions · Convert a stored date to a required format while querying the data. · Manipulating existing date time...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found