-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for width-aware noon and midnight options for DayPeriod (#…
…444) * Add support for NoonMidnight dayPeriods in test data. - Updates all of the JSON test data to contain fields for noon and midnight dayperiods. * Add DayPeriod symbols for NoonMidnight - Adds optional `DayPeriod` symbol for `noon`. - Adds optional `DayPeriod` symbol for `midnight`. * Add tests for DayPeirod AmPm and NoonMidnight patterns - Restructures `format` module to use directory structure instead of single file. - Adds a `format/tests` directory. - Moves existing local tests from `format.rs` to `format/tests/mod.rs` - Adds JSON test data for `DayPeriod` patterns. - Adds JSON-serializable structs for testing formatting patterns. - Adds test cases for `DayPeriod` patterns. - Adds parsing test cases for the `b` `DayPeriod` pattern. * Remove logic that handles 24:00 - 24:00 will not be a valid time once #355 is fixed. - Removes logic than handles 24:00 for now. * Refactor DayPeriod patterns tests to integration tests - Converts `DayPeriod` pattern tests to be integration tests. - Tests no longer direclty use the private `write_pattern()`. - Tests now mutate the `DatesV1` struct to the desired pattern, using `DateTimeFormat` to format the custom patterns. * Rewrite symbols!() macro to support serde_none seralization for Options - Rewrites the `symbols!()` macro as a token tree muncher. - For `Option` members, adds serde attributes to skip serializing if none. - Otherwise, includes them in the seralization. * Regenerate test data with optional serializtion for dayperiods - Regenerates the test data now that `noon` and `midnight` are skipped if not present. - Previously `noon` and `midnight` would show up as `null`. * Minor Test Cleanup - Moves a few expressions in the dayperiod patterns test to outer loops. * Make NoonMidnight dependent on granularity of pattern's time. - Adds capability for a pattern to compute its most granular time. - e.g. `h:mm:ss` is `Seconds`. - e.g. `h` is `Hours`. - e.g. `E, dd/MM/y` is `None`. - Patterns containing `b` the `NoonMidnight` pattern item will now display noon or midnight only if the displayed time falls on the hour. - This means that `12:00:00` is always noon-compatible. - However, `12:05:15` is noon-compatible only if the display pattern does not contain the minutes or seconds. * Move time granularity functions to format-local helper functions. - Time granularity functionality is no longer associated with Pattern or PatternItem. It is now local to the format module alone as standalone functions. * Move format/mod.rs to format.rs - Format no longer needs to be a directory. * Fix access specifiers - Makes TimeGranularity private instead of public. * Add minor DayPeriod formatting optimization. - Only calculates the time granularity if the `DayPeriod` is `NoonMidnight`. * Cache time granularity on Pattern - Converts `Pattern` from a tuple struct to a traditional struct. - Adds a new data member `time_granularity` to `Pattern`. - `time_granularity` is a lazily initialized, interrior-mutable cached value. - Makes `Pattern`'s data members private. - The cached `time_granularity` is dependent on the `Pattern`'s `items`. It is no longer safe to allow `items` to be publicly accessible, because mutating `items` must invalidate the cached granularity. - Adds new method `items()` to `Pattern` to return a slice of its items. - Implement `From<Vec<PatternItem>` for `Pattern` - This is out of convenience in many places where tuple-struct syntax was used previously. * Clean up Pattern::from_iter - Pattern::from_iter now uses Pattern::from::<Vec<_>> * Eagerly evaluate Pattern time granularity - `Pattern`'s time granularity is no longer lazily evaluated. - It is instead evaulated on construction. * Use filter_map instead of flat_map - filter_map is more specialized, and arguably more readable.
- Loading branch information
Showing
24 changed files
with
924 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.