Commit Graph

74 Commits

Author SHA1 Message Date
Thomas Lamprecht
7200cd7e23 time: bump version to 2.0.3-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-26 16:53:50 +01:00
Christian Ebner
17bc0ac616 time: also implement From<&TimeSpan> for f64
Extend the already present `From<TimeSpan> for f64` implementation to
allow using the reference as well. There is no need to take ownership
and consume the `TimeSpan` object for conversion.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-26 16:50:56 +01:00
Christian Ebner
548411808e time: fix typos in TimeSpan related docstring
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-26 16:50:56 +01:00
Thomas Lamprecht
9f135cf16e time: run cargo fmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-25 17:20:01 +01:00
Thomas Lamprecht
aa12dcbba0 time: bump version to 2.0.2-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-17 16:16:56 +02:00
Thomas Lamprecht
44e7ca98cd time: add some simple unit tests for time span conversions
For starters, could definitively be expanded.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-17 14:23:27 +02:00
Thomas Lamprecht
17bf3ec9fe time: add module level docs for time span
There was basically no documentation at all, so try to document the
basic format syntax and where it comes from. The text is partially
adapted from the systemd docs.

Could be still expanded with some example code and the methods might
do good with getting some docs too, but those parts can be relatively
easily be figured out from the code itself, the basic underlying
design and format background is much harder to guess..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-17 14:23:27 +02:00
Thomas Lamprecht
191299605f time: display minute/month such that it can be parsed again
Previously we displayed, e.g., "4m 1h 1min", i.e. using "m" for months
and "min" for minutes but "m"  was not accepted as month when parsing
a timespan string, so a 4 month timespan would be printed "4m" but if
parsed again it would result in a timespan of 4 minutes.

So switch month to an uppercase "M" and minute to the lower case "m",
which makes renderings of common timespans nicer, as in most of our
use cases they are in the range of minutes to hours, sometimes days
but seldom longer than weeks. So using single letters for all but
"min" stuck out quite a bit, e.g.: "1h 5min 2s" looks odd compared to
"1h 5m 1s"

While the duplicate letter is not 100% ideal it's still better than
the status quo, where rendering and parsing would interpret things
differently.
Also, the order still makes it quite clear, e.g.:
"7m 2w 3d 1h 5min 44s" now becomes "7M 2w 3d 1h 5m 44s"

As a side effect this also brings the display format closer to what is
used inside PVE backup job taks logs.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-17 14:22:44 +02:00
Thomas Lamprecht
9ae91303fd time: switch to inline template variables
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-17 11:40:21 +02:00
Christian Ebner
67822186a2 time: drop trailing space when not showing seconds at end
Seconds are not displayed when the value is smaller than 0.1s and
they are not at the start of the display output, e.g. `1h 2m`.
Drop the additional whitespace currently appended for this edge case.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-10-17 10:38:53 +02:00
Wolfgang Bumiller
d6e86d670b tree-wide: unify workspace inherited attributes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-09-20 08:42:45 +02:00
Wolfgang Bumiller
a88be21074 time: bump to 2.0.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 11:08:23 +02:00
Maximiliano Sandoval
669c39c59f time: remove lazy_static dependency
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 10:33:42 +02:00
Maximiliano Sandoval
c8b975799b fix typos in strings
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-07-22 08:49:42 +02:00
Maximiliano Sandoval
c88cdd7e67 fix typos in variable and function names
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-07-22 08:49:42 +02:00
Maximiliano Sandoval
254a37ae07 fix typos in code documentation
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-07-22 08:49:42 +02:00
Maximiliano Sandoval
72ab48eb55 fix typos in rust api documentation
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-07-22 08:49:42 +02:00
Wolfgang Bumiller
0652d81977 tree-wide: enable doc_cfg and doc_auto_cfg for docs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-07-02 11:59:53 +02:00
Wolfgang Bumiller
bb8460bc0f time: bump to 2.0.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 13:49:56 +02:00
Wolfgang Bumiller
214dbdf9a5 time: remove deprecated functions
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 13:48:42 +02:00
Wolfgang Bumiller
533954ed38 bump bitflags dependency to 2.4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 13:48:32 +02:00
Wolfgang Bumiller
1c5f27014c time: drop TryFrom/TryInto imports
they're in the prelude by now

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-19 14:55:41 +02:00
Shannon Sterz
a4be52d4a6 time: exclude certain use statements and impl block on wasm32
otherwise the compiler will complain that they aren't used when
compiling the code for wasm32.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2024-06-19 14:55:41 +02:00
Lukas Wagner
5cbc8a4b66 add proxmox-rrd to workspace
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-02-01 10:30:57 +01:00
Wolfgang Bumiller
ea05268cde bump proxmox-time to 1.1.6
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-01-08 12:18:12 +01:00
Lukas Wagner
1384bd9161 time: posix: add epoch_to_rfc2822
This is the format used in the 'Date' header in mails.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-01-08 12:04:11 +01:00
Lukas Wagner
795b3a57a7 time: posix: add bindings for strftime_l
This variant of strftime can be provided with a locale_t, which
determines the locale used for time formatting.

A struct `Locale` was also introduced as a safe wrapper around
locale_t.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-01-08 11:59:26 +01:00
Lukas Wagner
5b25e7cc90 time: posix: inline vars in string formatting
No functional changes.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-01-08 11:57:25 +01:00
Lukas Wagner
7033c497a0 time: posix: use strftime from the libc crate.
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-01-08 11:57:15 +01:00
Dietmar Maurer
c1819c2549 DailyDuration: derive PartialEq (for GUI)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-20 12:01:27 +02:00
Dominik Csapak
299a478f15 proxmox-time: implement epoch_to_rfc3339 for wasm
we just printed out the UTC version, this implements a localized version

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-08-30 09:20:38 +02:00
Dominik Csapak
151e2cfdfd time: make RFC3339 format in wasm conform to usual format
on other targets we print the timestamp without fractional seconds
('.xxxZ'), so we should remove that too on wasm

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-08-30 09:18:44 +02:00
Lukas Wagner
5ea70421b3 clippy fix: casting to the same type is unnecessary
See: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:48:01 +02:00
Wolfgang Bumiller
8f8d52f148 update d/copyright files to debian copyright-format 1.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-23 13:02:39 +02:00
Wolfgang Bumiller
2cebe420c1 bump proxmox-time to 1.1.5-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-01-12 14:23:11 +01:00
Dietmar Maurer
78e86f3261 re-add epoch_to_rfc3339_utc on wasm target
This was lost in commit 980d6b26df.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2022-12-15 13:35:53 +01:00
Fabian Grünbichler
de6a59289a proxmox-time: drop TryFrom use statement
no longer needed with edition 2021

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:47 +01:00
Fabian Grünbichler
6c161bd5ab update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00
Fabian Grünbichler
4189221470 inherit shared, external dependencies
noteworthy changes:
- proxmox-http had a default_features_false dep on hyper, which is dropped (the
  default feature is empty anyway)
- hyper, libc, nix, tokio and url versions are unified
- missing (cosmetic) bindgen feature on zstd enabled everywhere

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00
Fabian Grünbichler
64959d9ae0 move common metadata to workspace
and switch all crates to 2021 edition as well as a unified "authors" value.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:25 +01:00
Fabian Grünbichler
5ec765f842 update d/control files
debcargo 2.6 changed some minor details

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-06 11:21:43 +01:00
Fabian Grünbichler
28e30719e8 clippy fixes
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-10-11 09:48:04 +02:00
Fabian Grünbichler
9478ae2bed fixup! time: update to nom 7 2022-08-19 14:19:39 +02:00
Fabian Grünbichler
1344ffdd94 time: bump to 1.1.4
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-08-19 12:22:45 +02:00
Fabian Grünbichler
552f14e916 time: update to nom 7
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-08-19 12:22:27 +02:00
Wolfgang Bumiller
1fca7b715d time: clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-06-29 10:06:20 +02:00
Fabian Grünbichler
980d6b26df proxmox-time: add missing 1.1.3 change
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-02 14:33:12 +02:00
Thomas Lamprecht
9c0e9dca59 tree wide update of genereated control
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-05 10:22:50 +02:00
Dietmar Maurer
47c9bed30d impl epoch_to_rfc3339_utc on wasm target 2022-04-20 09:10:47 +02:00
Thomas Lamprecht
4554034d32 time: rustfmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-04-10 12:34:04 +02:00