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

Sort present dates according to decreasing #3

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

ryanzomorrodi
Copy link
Contributor

Format dates currently sorts present dates (which are na's) always last, but this yields counter-intuitive results when decreasing = TRUE:

work <- data.frame(
  title = c("Technical Assistant", "Junior Professor", "Associate Professor"),
  location = c("Bern, Switzerland", "Bern, Switzerland", "Zürich, Switzerland"),
  start = as.Date(c("1902-01-01", "1908-01-01", "1909-01-01")),
  end = as.Date(c("1908-01-01", "1909-01-01", NA)),
  description = c("Federal Patent Office", "University of Bern", "University of Zürich")
)

work |>
  format_date(end = "end", date_format = "%Y", sort_by = "end", decreasing = TRUE) |>
  resume_entry()
#> ```{=typst}
#> #resume-entry(title: "Junior Professor",location: "Bern, Switzerland",date: "1908 - 1909",description: "University of Bern",)
#> #resume-entry(title: "Technical Assistant",location: "Bern, Switzerland",date: "1902 - 1908",description: "Federal Patent Office",)
#> #resume-entry(title: "Associate Professor",location: "Zürich, Switzerland",date: "1909 - Present",description: "University of Zürich",)
#> ```

This change sets na.last to the opposite of decreasing so present dates will be first when decreasing = TRUE and last when decreasing = FALSE

@kazuyanagimoto kazuyanagimoto merged commit 7166161 into kazuyanagimoto:main Nov 4, 2024
3 checks passed
@kazuyanagimoto
Copy link
Owner

Thanks for contributing it again!

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.

2 participants