Style for FORMAT_DATE_DDMMYYYY

Issue #420 resolved
Bors LTD
created an issue

Hi, in openpyxl/styles/numbers.py:

FORMAT_DATE_DDMMYYYY = 'dd/mm/yy'

Is there a reason the constant is called with a four-digit year but the actual format will use a two-digit year? It seems misleading to me.

But maybe the issue is with Excel?

Comments (4)

  1. Charlie Clark

    I think we copied it over from existing code like that. I agree it's misleading but I never use the constant names myself here. US_date would probably be better.

    Feel free to submit a PR with improvements.

  2. Charlie Clark

    I don't think there's a built-in for that. :-/ To make matters worse some formats are client locale specific.

    We've essentially standardised on ISO for Python datetimes (search for bug on this) and this is a custom format. If you know what you're doing you will be able to hack that in 2.2 just before you save a file by overwriting the relevant value un wb._number_formats.

    I'm hoping to add support for named styles in a future version. This may, hopefully, allow you to work with a standard format where you could simply define the number format for the default named styles once. NB. it would still be a custom format! Named styles are available in those pulldowns. Absurdly, the localised names get stored in the files if the definitions get edited. Waiting for clarification on this before doing any more work.

  3. Log in to comment