graphene-sqlalchemy icon indicating copy to clipboard operation
graphene-sqlalchemy copied to clipboard

Formatting datetime-like columns

Open thejcannon opened this issue 6 years ago • 3 comments

It'd be nice to be able to specify a strftime string which would automatically be used when resolving datetime-like columns so the user gets a friendly value.

thejcannon avatar Apr 15 '19 20:04 thejcannon

Please provide an example of what the API would look like.

jnak avatar Apr 15 '19 21:04 jnak

Probably using the Meta options:

class Book(SQLAlchemyObjectType):
   class Meta:
      model = models.Book
      time_format = '%a, %d %b %Y %H:%M:%S'

thejcannon avatar Apr 15 '19 21:04 thejcannon

Sounds helpful! However, I don't think a Meta entry would be the right place for this since some models might require different time formats in the same response. The approach should allow field-level adjustments, but an additional default global option is also handy. I'm open to more suggestions.

However, I think this is rather low-priority since formatting is usually a front-end task and the current ISO8601 date strings enable all of that.

erikwrede avatar Apr 28 '22 17:04 erikwrede

Closing this as part of triage, since this is an issue that is easily solvable in the frontend, as mentioned above. Please open a new issue with detailed examples, if you need this feature.

erikwrede avatar Feb 15 '23 10:02 erikwrede

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue.

github-actions[bot] avatar Aug 15 '23 00:08 github-actions[bot]