feat: add --time-format parameter for parse and search commands#104
Merged
feat: add --time-format parameter for parse and search commands#104
Conversation
Add configurable timestamp output format for non-JSON output formats in parse and search commands. - Add TimestampFormat enum with 'unix' (default) and 'rfc3339' variants - Unix format: Output timestamps as integer/float (e.g., 1697043600) - RFC3339 format: Output timestamps in ISO 8601 format (e.g., 2023-10-11T17:00:00+00:00) - JSON output always uses numeric timestamps for backward compatibility - Affects table, psv, and markdown output formats
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
--time-formatparameter tomonocle parseandmonocle searchcommands to control how timestamps are displayed in output.Features
--time-format unix(default): Output timestamps as Unix epoch (integer or float)1697043600or1697043600.5--time-format rfc3339: Output timestamps in ISO 8601/RFC3339 format2023-10-11T17:00:00+00:00Usage Examples
Together with
--format tableand--fields timestamp,prefix,as_path, the updated command results can look much cleaner:Backward Compatibility
--time-format unixis the default, maintaining existing output format--time-formatsetting, ensuring backward compatibility for scripts that parse JSON outputImplementation Details
TimestampFormatenum tosrc/lens/utils.rswith variantsUnixandRfc3339elem_format.rsto support timestamp formatting viaget_field_value_with_time_format()--time-formatCLI argument to bothparse.rsandsearch.rscommandsbuild_json_object) continue to usejson!(elem.timestamp)to preserve numeric output