Skip to content

Commit 63cce06

Browse files
LarsEckartJayBazuziisidore
committed
- B DateScrubber.getScrubberFor now handles timestamps with sub second precision
Co-authored-by: Jay Bazuzi <jay@bazuzi.com> Co-authored-by: Llewellyn Falco <llewellyn.falco@gmail.com>
1 parent 88ec81a commit 63cce06

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

approvaltests-tests/src/test/java/org/approvaltests/scrubbers/DateScrubberTest.supportedFormats.approved.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
| 2024-12-17 | \d{4}-\d{2}-\d{2} |
2020
| 2024-12-18T14:04:46.746130Z | \d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}:\d{2}(\.\d{1,9})?Z |
2121
| 13/05/2014 23:50:49 | \d{2}[-/.]\d{2}[-/.]\d{4}\s\d{2}:\d{2}(:\d{2})?( (?:pm\|am\|PM\|AM))? |
22-
| 2025-05-15 16:57:04.599 | \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} |
22+
| 2025-05-15 16:57:04.599 | \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ |
2323

2424

approvaltests-tests/src/test/java/org/approvaltests/scrubbers/DateScrubberTest.testGetDateScrubber.approved.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ Example: {'date':"[Date1]"}
137137

138138

139139
Scrubbing for 2025-05-15 16:57:04.599:
140-
RegExScrubber[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}]
140+
RegExScrubber[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+]
141+
Example: {'date':"[Date1]"}
142+
143+
144+
Scrubbing for 2025-05-19 19:45:04.99:
145+
RegExScrubber[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+]
141146
Example: {'date':"[Date1]"}
142147

143148

approvaltests/src/main/java/org/approvaltests/scrubbers/DateScrubber.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public static SupportedFormat[] getSupportedFormats()
4747
__("\\d{2}[-/.]\\d{2}[-/.]\\d{4}\\s\\d{2}:\\d{2}(:\\d{2})?( (?:pm|am|PM|AM))?",
4848
"13/05/2014 23:50:49", "13.05.2014 23:50:49", "13-05-2014 23:50:49",
4949
"13.05.2014 23:50", "05/13/2014 11:50:49 PM"),
50-
__("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3}",
51-
"2025-05-15 16:57:04.599"),};
50+
__("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d+", "2025-05-15 16:57:04.599",
51+
"2025-05-19 19:45:04.99")};
5252
}
5353
private static SupportedFormat __(String regex, String... examples)
5454
{

0 commit comments

Comments
 (0)