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

time span format verbosity #1183

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

neilboyd
Copy link
Contributor

@neilboyd neilboyd commented Feb 23, 2022

Fixes #571
Fixes #642
Fixes #969

Based on HeadingStyle (although that's inconsistent with WordForm).

Replace timeSpan.Humanize(toWords: true) with timeSpan.Humanize(timeSpanStyle: TimeSpanStyle.Words).
This is a breaking change.

timeSpan.Humanize() remains unchanged, although the optional parameter has changed from toWords: false to timeSpanStyle: TimeSpanStyle.Full.

Added timeSpan.Humanize(timeSpanStyle: TimeSpanStyle.Abbreviated) and timeSpan.Humanize(timeSpanStyle: TimeSpanStyle.Short).
These return English regardless of the locale.

Question: how do you normally handle translation in this project? I could add tests for every language, where Abbreviated and Short return English for every locale, or not, or I could create translations (and tests) for every language (I could make a best guess for Latin and Cyrillic alphabets, but not the others).

Question: should we use uppercase for Y, D, W? (M is already uppercase in order to disambiguate with minute)


Here is a checklist you should tick through before submitting a pull request:

  • Implementation is clean
  • Code adheres to the existing coding standards; e.g. no curlies for one-line blocks, no redundant empty lines between methods or code blocks, spaces rather than tabs, etc.
  • No Code Analysis warnings
  • There is proper unit test coverage
  • If the code is copied from StackOverflow (or a blog or OSS) full disclosure is included. That includes required license files and/or file headers explaining where the code came from with proper attribution
  • There are very few or no comments (because comments shouldn't be needed if you write clean code)
  • Xml documentation is added/updated for the addition/change
  • Your PR is (re)based on top of the latest commits from the main branch (more info below)
  • Link to the issue(s) you're fixing from your PR description. Use fixes #<the issue number>
  • Readme is updated if you change an existing feature or add a new one
  • Run either build.cmd or build.ps1 and ensure there are no test failures

@neilboyd neilboyd mentioned this pull request Feb 25, 2022
11 tasks
@neilboyd neilboyd force-pushed the time-span-verbosity branch 4 times, most recently from b182b10 to 56d4937 Compare March 7, 2022 06:28
@neilboyd neilboyd marked this pull request as ready for review March 22, 2022 06:26
@neilboyd
Copy link
Contributor Author

I think it's ready, but there are some questions in the description

@SimonCropp
Copy link
Collaborator

@hazzik thoughts on this one?

one note is that it significantly increase the number of entries in all the resource files. but if the entry is missing it can sensibly fall back to an acceptable value

@hazzik
Copy link
Member

hazzik commented Feb 22, 2024

I'm refactoring this whole thing into using fewer resources:

DateHumanize_MultipleDaysFromNow ("{0} days from now") would become:

DateHumanize_Future => "{0} from now" (new resource) and
TimeSpanHumanize_MultipleDays => "{0} days" (existing resource)

After that refactoring we could start thinking about abbreviations.

@SimonCropp
Copy link
Collaborator

@hazzik awesome. love your work

@hazzik
Copy link
Member

hazzik commented Feb 22, 2024

I've tried to refactor *Ago and *FromNow. Unfortunately it is not an easy task :( Too many language specific rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abbreviate time units Time units Minimize verbosity of Timespan formatting.
4 participants