Skip to content
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

Use isoformat for dates when producing json output in cloud commands #1029

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

gcalacoci
Copy link
Contributor

@gcalacoci gcalacoci commented Oct 29, 2024

This patch modifies the to_json() method of the BackupInfo class
substituting the ctime method from the datetime class with the
isoformat method, when printing begin_time and end_time
in json format.

The new format preserves all the relevant informations of the datetime
object, including the timezone.

References: bar-316

Copy link
Contributor

@barthisrael barthisrael left a comment

Choose a reason for hiding this comment

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

From what I can see, the begin_time and end_time are always set with a time zone. With that in mind, I think we can simply proceed they way you are doing, i.e. replacing ctime with isoformat.

The changes look good.

As a side comment, I was wondering if we should take the opportunity to add unit tests for barman-cloud-backup-list with JSON output? Currently we have only for console mode.

This patch modifies the `to_json()` method of the BackupInfo class
substituting the `ctime` method from the datetime class with the
`isoformat` method, when printing `begin_time` and `end_time`
in json format.

The new format preserves all the relevant informations of the datetime
object, including the timezone.

References: bar-316

Signed-off-by: Giulio Calacoci <[email protected]>
References: bar-316

Signed-off-by: Giulio Calacoci <[email protected]>
@gcalacoci gcalacoci merged commit b6baaf3 into master Oct 30, 2024
11 checks passed
@gcalacoci gcalacoci deleted the dev/bar-316 branch October 30, 2024 10:52
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