ApprovalTests.Python icon indicating copy to clipboard operation
ApprovalTests.Python copied to clipboard

Have date scrubber allow all possible datetime formats as an array

Open jmasonlee opened this issue 3 years ago • 0 comments

I have logs, but I don't have full control over the format of those logs.

Some of the dates in my logs look like this: 2022-08-11

Some of the dates in my logs look like this: 2022-08-11 14:03:49.911513

Some of the dates in my logs look like this: 2022-08-11 14:03:49

Only the last one is properly scrubbed by scrub_all_dates.

I like this for scrubbing a default date pattern: options=Options().with_scrubber(scrub_all_dates)

I also want to be able to do something like this: date_formats = ["%Y-%m-%d", "%Y-%m-%d %H:%M:%S:%f", "%Y-%m-%d %H:%M:%S" ] options=Options().with_scrubber(scrub_all_dates(date_formats))

Here is the docs on datetime formatting in python: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes

I'm not sure when I will be able to join next, so I'm documenting this here in case you feel like doing it before then :-)

I can work around this for now

jmasonlee avatar Aug 11 '22 14:08 jmasonlee