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

Allow two-digit-max-year customization in patterns #1721

Merged
merged 1 commit into from Jun 3, 2023

Conversation

jskeet
Copy link
Member

@jskeet jskeet commented Nov 4, 2022

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Nov 4, 2022

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (b81a841) 99.35% compared to head (7b140e9) 99.35%.

❗ Current head 7b140e9 differs from pull request most recent head 838afe8. Consider uploading reports for the commit 838afe8 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1721   +/-   ##
=======================================
  Coverage   99.35%   99.35%           
=======================================
  Files         155      155           
  Lines        6988     7024   +36     
=======================================
+ Hits         6943     6979   +36     
  Misses         45       45           
Impacted Files Coverage Δ
src/NodaTime/Globalization/NodaFormatInfo.cs 100.00% <100.00%> (ø)
src/NodaTime/Text/InstantPattern.cs 100.00% <100.00%> (ø)
src/NodaTime/Text/InstantPatternParser.cs 100.00% <100.00%> (ø)
src/NodaTime/Text/LocalDatePattern.cs 100.00% <100.00%> (ø)
src/NodaTime/Text/LocalDatePatternParser.cs 100.00% <100.00%> (ø)
src/NodaTime/Text/LocalDateTimePattern.cs 100.00% <100.00%> (ø)
src/NodaTime/Text/LocalDateTimePatternParser.cs 100.00% <100.00%> (ø)
src/NodaTime/Text/OffsetDatePattern.cs 100.00% <100.00%> (ø)
src/NodaTime/Text/OffsetDatePatternParser.cs 100.00% <100.00%> (ø)
src/NodaTime/Text/OffsetDateTimePattern.cs 100.00% <100.00%> (ø)
... and 6 more

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jskeet jskeet changed the title First draft of allowing two-digit-max-year customization Allow two-digit-max-year customization in patterns Jun 3, 2023
@jskeet jskeet force-pushed the two-digit-year branch 2 times, most recently from 2fe5b16 to 6cf5ce2 Compare June 3, 2023 10:11
@jskeet jskeet marked this pull request as ready for review June 3, 2023 11:01
@jskeet jskeet requested a review from malcolmr June 3, 2023 11:02
@jskeet
Copy link
Member Author

jskeet commented Jun 3, 2023

It's been a while, but I think this is ready now :) Lots of copy/paste, so if you find any typos in docs etc, I'll no doubt need to fix them everywhere...

Copy link
Contributor

@malcolmr malcolmr left a comment

Choose a reason for hiding this comment

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

LGTM

/// <summary>
/// Maximum two-digit-year in the template to treat as the current century.
/// </summary>
public int TwoDigitYearMax { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

optional: worth adding a <value> per above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

/// <summary>
/// Creates a pattern like this one, but with a different <see cref="TwoDigitYearMax"/> value.
/// </summary>
/// <param name="twoDigitYearMax">The value to use for <see cref="TwoDigitYearMax"/> in the new pattern.</param>
Copy link
Contributor

Choose a reason for hiding this comment

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

worth adding something like "The value (0-99) to use..." to make the range clear?

Separately, where do we document the default values for this type? Probably we should document the default value for this new property?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Will add the default into the description of the property.

@jskeet
Copy link
Member Author

jskeet commented Jun 3, 2023

Thanks for the review - will merge when I've finished tweaking the docs, and when it's gone greeen.

Fixes nodatime#1720, at least the main feature.

Additional potential features to be implemented later:

- WithTwoDigitYearMaxFromCalendar
- An AppContext switch to prohibit two-digit years in patterns
@jskeet jskeet merged commit ea27513 into nodatime:main Jun 3, 2023
2 checks passed
@jskeet jskeet deleted the two-digit-year branch June 3, 2023 16:50
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.

None yet

3 participants