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

Render the date with Dec 31st as year only #65

Closed
eplodn opened this issue Sep 12, 2022 · 5 comments · Fixed by #67
Closed

Render the date with Dec 31st as year only #65

eplodn opened this issue Sep 12, 2022 · 5 comments · Fixed by #67
Assignees
Labels
enhancement New feature or request

Comments

@eplodn
Copy link

eplodn commented Sep 12, 2022

Currently, my LinkedIn profile contains only years, and these are rendered as Dec 31 of that year on export.

After the processing, all the dates in my CV are rendered as "December" of some year.

An enhancement proposed is to render "XXXX-12-31" as "XXXX".

@alexpovel
Copy link
Owner

alexpovel commented Sep 12, 2022

Hey! Thank you for submitting your issue.

I had discussed this (with myself..) in #45 . I guess we can all agree day precision doesn't matter on a CV. Omitting months as well is a good use case. While I can flat-out ignore day info, I can't globally disable month info -- most people will want it.

So you'd require customization. Some options are:

  1. We could trivially add a new theme with a new datefmt:

    datefmt: str

    That date format could then just read yyyy. The current default theme, lollipop, uses MMMM yyyy so that's what you're seeing:

    datefmt="MMMM yyyy",

    This would be a global setting for all your dates. You would no longer be able to show month info for any of your dates. Would that work for you?

  2. A toggle (like ascii_only) could be introduced to drop all month info and only print years. The result would be the same as 1.

  3. I could look into accepting date strings verbatim. This would give you full control, but it's also laboursome and not quite in line with the original JSON Resume schema.

  4. Rendering YYYY-12-31 as just YYYY... I'm not sure about the implications. It would certainly be non-obvious.

Do you have a preference?

@alexpovel alexpovel self-assigned this Sep 13, 2022
@alexpovel alexpovel added the question Further information is requested label Sep 13, 2022
@eplodn
Copy link
Author

eplodn commented Sep 13, 2022

I'd be good with any option frankly, the root cause here is that while the range "2012-2015" is perfectly valid in a CV, it can't be properly rendered in json schema, as that requires a precise date.

A possibility would be to change

return format_date(date, format=self.theme.datefmt, locale=self.locale)

to something to the tune of:

format = self.theme.datefmt
if date.month == 12 and date.day == 31:
    format = 'YYYY'
return format_date(date, format=format, locale=self.locale)

That, indeed, might be non-obvious, as you mention.

@alexpovel
Copy link
Owner

As far as I see, the LinkedIn exporter will give the last day of the months as its default, so anyone having worked from December of some year to December of another would be caught by the implicitness. I'm leaning towards a (global) toggle to drop month info altogether for the entire CV. That'd be fast to implement and backwards-compatible. I'll look into that this weekend.

@eplodn
Copy link
Author

eplodn commented Sep 14, 2022

Thanks Alex.

As a side note, someone who worked from December of some year would likely prefer to not have the month presented.
Instead of

December 2016 — December 2017

one would have

2016 — 2017

This, while not being technically incorrect, makes it look longer 😃

@alexpovel
Copy link
Owner

alexpovel commented Sep 18, 2022

This should be a decently usable feature; I ended up sticking to your 'Dec. 31st as year' proposal:

def format_date(self, date: date) -> str:
format = self.theme.datefmt.full
is_last_doy = date.month == date.max.month and date.day == date.max.day
if is_last_doy and self.dec31_as_year:
format = self.theme.datefmt.year_only
return format_date(date, format=format, locale=self.locale)

but with an opt-in toggle in front of it, such that it's not a breaking change. With the toggle set to true (default false), all dates YYYY-12-31 will render as YYYY. Collapsing also works (start and end in the same year will display that year only once, not twice). Perhaps the newly added tests are an indication of how you can expect this to work:

26d46cb#diff-e3b4a4168a83e12235447e3ffa376405587986648a93376faace1df424704877R178-R265

Please let me know if you find any bugs or have any further remarks.

@alexpovel alexpovel added enhancement New feature or request and removed question Further information is requested labels Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants