Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recipes #8

Open
techtonik opened this issue Aug 26, 2014 · 7 comments
Open

Add recipes #8

techtonik opened this issue Aug 26, 2014 · 7 comments

Comments

@techtonik
Copy link

There are many gotchas with formatting time, getting right time/date/datetime object, and choosing right syntax for popular formats. It would help to have a preformatted copy-pasteable snippets. I'd personally need 2014-08-27 01:00:00.00000 in UTC, but other formats, such as full ISO 8601 format are useful too.

@mccutchen
Copy link
Owner

@techtonik I think this is a good idea, but I'm having a hard time thinking of good examples.

I'd personally need 2014-08-27 01:00:00.00000 in UTC

What format is that? How would you picture this being displayed?

Re: ISO 8601 formatting, is there something missing from datetime.isoformat()? Would that example just tell people to use that method?

@techtonik
Copy link
Author

techtonik commented Sep 4, 2014

I'd personally need 2014-08-27 01:00:00.00000 in UTC

What format is that? How would you picture this being displayed?

Re: ISO 8601 formatting, is there something missing from datetime.isoformat()? Would that example just tell people to use that method?

Yes, string returned by datetime.isoformat() is not fixed length. If microseconds are 0, it returns 2014-08-27 01:00:00

@mccutchen
Copy link
Owner

Another possible example I recently came across on my own that might be useful: Parsing the date strings returned by the Twitter API:

>>> datetime.datetime.strptime('Wed Jun 06 20:07:10 +0000 2012', '%a %b %d %H:%M:%S +0000 %Y')
datetime.datetime(2012, 6, 6, 20, 7, 10)

@lonetwin
Copy link

@RichardBronosky
Copy link

Rather than dump a bunch of examples, you could use JS to make a demo. It would just take 1 text field for the format string and an element in which to place the result. Make the codes clickable so that someone can come to the page, click a bunch of codes in the order they want, copy, and go.

You'd want to put a delimiter (like a space) after each clicked code and allow the user to either edit or remove to get their preference.

@techtonik
Copy link
Author

@RichardBronosky can you demonstrate what are you speaking about? Is it some kind of interactive Jupyter notebook?

@treyhunner
Copy link

I made a tool that attempts to guess the format you need based on a datetime string: https://pym.dev/strptime

That page also includes a list of common formats to pick from (direct link to that here).

I've been a happy user of https://strftime.org for years but I was wanting something that's a bit more opinionated about the full format string. I linked to https://strftime.org and https://www.strfti.me (which I discovered from strftime.org) on that page because I still find these simple format code cheat sheets very useful, especially when working with odd datetime formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants