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

Include examples #16

Open
zborboa-g opened this issue Mar 24, 2016 · 2 comments
Open

Include examples #16

zborboa-g opened this issue Mar 24, 2016 · 2 comments

Comments

@zborboa-g
Copy link

Would you be interested in a pull request that adds examples of commonly used formats for strftime?

@zborboa-g
Copy link
Author

DATE_INPUT_FORMATS = [
    '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y',  # '2006-10-25', '10/25/2006', '10/25/06'
    '%b %d %Y', '%b %d, %Y',             # 'Oct 25 2006', 'Oct 25, 2006'
    '%d %b %Y', '%d %b, %Y',             # '25 Oct 2006', '25 Oct, 2006'
    '%B %d %Y', '%B %d, %Y',             # 'October 25 2006', 'October 25, 2006'
    '%d %B %Y', '%d %B, %Y',             # '25 October 2006', '25 October, 2006'
]

TIME_INPUT_FORMATS = [
    '%H:%M:%S',     # '14:30:59'
    '%H:%M:%S.%f',  # '14:30:59.000200'
    '%H:%M',        # '14:30'
]

DATETIME_INPUT_FORMATS = [
    '%Y-%m-%d %H:%M:%S',     # '2006-10-25 14:30:59'
    '%Y-%m-%d %H:%M:%S.%f',  # '2006-10-25 14:30:59.000200'
    '%Y-%m-%d %H:%M',        # '2006-10-25 14:30'
    '%Y-%m-%d',              # '2006-10-25'
    '%m/%d/%Y %H:%M:%S',     # '10/25/2006 14:30:59'
    '%m/%d/%Y %H:%M:%S.%f',  # '10/25/2006 14:30:59.000200'
    '%m/%d/%Y %H:%M',        # '10/25/2006 14:30'
    '%m/%d/%Y',              # '10/25/2006'
    '%m/%d/%y %H:%M:%S',     # '10/25/06 14:30:59'
    '%m/%d/%y %H:%M:%S.%f',  # '10/25/06 14:30:59.000200'
    '%m/%d/%y %H:%M',        # '10/25/06 14:30'
    '%m/%d/%y',              # '10/25/06'
]

https://github.com/django/django/blob/master/django/conf/global_settings.py#L343

@mccutchen
Copy link
Owner

@zborboa-google this is an interesting idea, but to be honest I'm a little hesitant to add more info to the page and I'm not sure I see the value in enumerating most of the examples pasted in above as they're trivial combinations of the formatting directives already listed.

I could see adding recipes for specific date/time formats that are tricky to get right, but I'm not sure what those would be. ISO-8601 is the only thing that leaps to my mind, but there's already the datetime.isoformat() method to handle that.

If you want to work up a pull request that implements some of this, I'd be happy to take a look! I just want to be up front about my reluctance to further clutter the page!

See a similar discussion in #8, which I'm just now realizing I've left hanging for a long time now.

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

2 participants