Skip to content

Commit

Permalink
zfs_get: change time format string from %k to %H
Browse files Browse the repository at this point in the history
Issue openzfs#10090 reported that snapshots created between midnight and 1 AM
are missing a padded zero in the creation property

This change fixes the bug reported in issue openzfs#10090 where snapshots
created between midnight and 1 AM were missing a padded zero in the
creation timestamp output.

The leading zero was missing because the time format string used `%k`
which formats the hour as a decimal number from 0 to 23 where single
digits are preceded by blanks[0] and is fixed by changing it to `%H`
which formats the hour as 00-23.

The difference in output is as below

```
-Thu Mar 26  0:39 2020
+Thu Mar 26 00:39 2020
```

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Alex John <alex@stty.io>
Closes openzfs#10090 
Closes openzfs#10153
  • Loading branch information
spaghetti- authored and tonyhutter committed Apr 22, 2020
1 parent b53ef75 commit fd44ea2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5964,7 +5964,7 @@ typedef struct holds_cbdata {
size_t cb_max_taglen;
} holds_cbdata_t;

#define STRFTIME_FMT_STR "%a %b %e %k:%M %Y"
#define STRFTIME_FMT_STR "%a %b %e %H:%M %Y"
#define DATETIME_BUF_LEN (32)
/*
*
Expand Down

0 comments on commit fd44ea2

Please sign in to comment.