Skip to content

fix: support anything coercer supports for date parsing #1078

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

Merged
merged 5 commits into from
Aug 20, 2021

Conversation

aaron-steinfeld
Copy link
Contributor

@aaron-steinfeld aaron-steinfeld commented Aug 19, 2021

Description

Dates coming through as strings, even though we have the tools to parse them, are not supported today in the table parser or the date display pipe. This adds that support.

Testing

Manual, added UTs

@aaron-steinfeld aaron-steinfeld requested a review from a team as a code owner August 19, 2021 23:31
@codecov
Copy link

codecov bot commented Aug 19, 2021

Codecov Report

Merging #1078 (6147b9e) into main (36aaeea) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1078   +/-   ##
=======================================
  Coverage   85.08%   85.08%           
=======================================
  Files         822      822           
  Lines       16924    16928    +4     
  Branches     2045     2045           
=======================================
+ Hits        14399    14404    +5     
+ Misses       2494     2493    -1     
  Partials       31       31           
Impacted Files Coverage Δ
...ects/common/src/utilities/coercers/date-coercer.ts 100.00% <100.00%> (ø)
...on/src/utilities/formatters/date/date-formatter.ts 84.84% <100.00%> (+4.84%) ⬆️
...src/utilities/formatters/date/display-date.pipe.ts 100.00% <100.00%> (ø)
.../cells/data-parsers/table-cell-timestamp-parser.ts 86.66% <100.00%> (+2.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 36aaeea...6147b9e. Read the comment docs.

@github-actions

This comment has been minimized.

return value !== null ? new DateFormatter(options).format(value) : '-';
private readonly dateCoercer: DateCoercer = new DateCoercer();
public transform(value?: string | Date | number | null, options: DateFormatOptions = {}): string {
return isNil(value) ? '-' : new DateFormatter(options).format(this.dateCoercer.coerce(value));
Copy link
Contributor

Choose a reason for hiding this comment

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

what if this.dateCoercer.coerce(value) returns undefined? Should we do this before the calling isNil so that we can assign '-'?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the DateFormatter just depend on dateCoercer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@aaron-steinfeld aaron-steinfeld merged commit 322ee99 into main Aug 20, 2021
@aaron-steinfeld aaron-steinfeld deleted the more-dates branch August 20, 2021 01:07
@github-actions
Copy link

Unit Test Results

    4 files  ±0  265 suites  +2   17m 21s ⏱️ -54s
951 tests +4  951 ✔️ +4  0 💤 ±0  0 ❌ ±0 
958 runs  +4  958 ✔️ +4  0 💤 ±0  0 ❌ ±0 

Results for commit 322ee99. ± Comparison against base commit 36aaeea.

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