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

Fixes #877 - Updates date format #3240

Closed
wants to merge 7 commits into from
Closed

Conversation

anselmbradford
Copy link
Member

Fixes #877

Changes

  • Changes date format to include period and remove leading zeros.

Testing

  1. The following pages should have a date in the format of MMM. DD, YYYY (without leading zero):
  • /policy-compliance/notice-opportunities-comment/open-notices/
  • /blog/
  • /activity-log/
  • /about-us/events/
  • /about-us/careers/

Screenshots

screen shot 2017-08-11 at 11 43 22 am

screen shot 2017-08-11 at 11 42 44 am

screen shot 2017-08-11 at 11 42 50 am

screen shot 2017-08-11 at 11 43 07 am

screen shot 2017-08-11 at 11 42 57 am

@anselmbradford
Copy link
Member Author

Added update to convert jobs table date:
screen shot 2017-08-11 at 11 58 43 am

@sarahsimpson09
Copy link
Contributor

@anselmbradford This looks good, but I have one question--what about May? Will the period be removed or will it look like "May. 9, 2017"?

@anselmbradford
Copy link
Member Author

Pushed the May and Sept. fixes:

screen shot 2017-08-11 at 1 43 04 pm

screen shot 2017-08-11 at 1 42 51 pm

@anselmbradford
Copy link
Member Author

Fixed the tests.

@@ -41,3 +41,20 @@
{% endif %}
</span>
{% endmacro %}

{% macro render_date_no_markup(datetime,
Copy link
Contributor

@sebworks sebworks Aug 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ehhhh, I'm not crazy about it. @richaagarwal, do you know a better way to write this code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's awesome! Best code I've ever written! Look at all the brackets!

@richaagarwal
Copy link
Contributor

richaagarwal commented Aug 14, 2017

Why is this necessary? :) And/or did anyone request this?

There are probably ways to write this a little more cleanly and I am happy to pair or brainstorm, but wanted to understand the need first.

@anselmbradford
Copy link
Member Author

anselmbradford commented Aug 15, 2017

@richaagarwal See the "dates and date ranges" section in the content strategy doc linked via https://[GHE]/UX/Content-Strategy
I posted a comment there about clarifying the comment on the blog dates is about perceived technical limitations imposed by wagtail.

{{ 'Sept. {dt.day}, {dt.year}'.format(dt = datetime) }}
{% else %}
{{ '{dt:%b}. {dt.day}, {dt.year}'.format(dt = datetime) }}
{% endif %}
Copy link
Member

@willbarton willbarton Aug 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent some time thinking about this and looking at possible alternatives. I couldn't find a Python library that has built-in support for formatting months like this (conditionality around when a month is abbreviated and to what character-number).

At the very least, I don't think this should be in the template itself, it should be a filter or something similar that can be called from any template (particularly if this is the standardized way to refer to dates) and can be properly unittested.

It would also simplify the logic greatly to use a mapping (like Python's build-in datetime library) of month number to abbreviation instead of ifs/elses.

Copy link
Member

@willbarton willbarton Aug 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it further, a custom wrapper around strftime that either introduces our own format code or handles %b differently from the standard library would mean we could actually use date formatting here (instead of dt.month, dt.day, dt.year) and in all the other places in this changeset like we should be doing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all sounds well and good and over my head 😄

@richaagarwal
Copy link
Contributor

@anselmbradford Thanks for the background! That's interesting. I didn't see anyone reply to your comment -- was consensus reached elsewhere? I don't think we should be making these changes unless someone really wants them. If we do proceed, I agree with @willbarton that a wrapper around strftime would make the most sense.

@anselmbradford
Copy link
Member Author

Closing this astoundingly stale PR, but leaving the associated issue open and updating the issue with context that a wrapper around strftime would be likely needed.

@cwdavies cwdavies deleted the updates_date_format branch April 7, 2020 17:22
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

Successfully merging this pull request may close these issues.

5 participants