Commit Graph

19 Commits

Author SHA1 Message Date
Thomas Waldmann 54a85bf56d
format_timedelta: use 3 decimal digits (ms)
maybe this fixes the frequently failing test.
also, giving ms makes more sense than 10ms granularity.
2024-04-04 12:45:28 +02:00
Michael Deyaso b2654bc17d
Support for date-based matching during archive listing (#7272)
check --archives: add --newer/--older/--newest/--oldest, fixes #7062

Options accept a timespan, like Nd for N days or Nm for N months.

Use these to do date-based matching on archives and only check some of them,
like: borg check --archives --newer=1m --newest=7d

Author: Michael Deyaso <mdeyaso@fusioniq.io>
2023-01-23 15:00:05 +01:00
Thomas Waldmann 9460da42d1
use local time / local timezone to output timestamps, fixes #7283
"ls" and also "tar" show timestamps as local time.
borg now does the same, but also shows the local tzoffset.

this also affects JSON output.
2023-01-19 03:36:46 +01:00
Thomas Waldmann 15139a80c9
bugfix: switch archive timestamps to utc
we use utc for file timestamps and manifest timestamp,
so let's use utc for archives also.
2022-12-04 10:55:20 +01:00
Thomas Waldmann 1f859c9f17
refactor: get archive timestamps via archive_ts_now() 2022-12-04 10:55:17 +01:00
Thomas Waldmann 87e597011a
bugfix: file timestamps should use tz-aware utc datetime objs
the UNIX time used for timestamp is seconds since 1.1.1970,
in UTC. thus, the natural way to represent it is with a
tz-aware utc datetime object.

but previously (in borg 1.x), they used naive datetime
objects and localtime.
2022-12-04 09:07:29 +01:00
Thomas Waldmann 4ab07b6acb create/recreate/import-tar --timestamp: default to local timezone
if you want to give UTC, just append: +00:00
2022-08-13 19:17:10 +02:00
Thomas Waldmann ade08ce842 use timezones
- timezone aware timestamps
- str representation with +HHMM or +HH:MM
- get rid of to_locatime
- fix with_timestamp
- have archive start/end time always in local time with tz or as given
- idea: do not lose tz information

then we know when a backup was made and even from
which timezone it was made. if we want to compute
utc, we can do that using these infos.

this makes a quite nice archives list, with timestamps
as expected (in local time with timezone info).

at some places we just enforce utc, like for the
repo manifest timestamp or for the transaction log,
these are usually not looked at by the user.
2022-08-13 18:31:22 +02:00
Thomas Waldmann bab68a8d25 use py37+ datetime.isoformat / .fromisoformat
since python 3.7, .isoformat() is usable IF timespec != "auto"
is given ("auto" [default] would be as evil as before, sometimes
formatting with, sometimes without microseconds).

also since python 3.7, there is now .fromisoformat().
2022-08-11 21:18:56 +02:00
Thomas Waldmann 7957af562d blacken all the code
https://black.readthedocs.io/
2022-07-06 16:34:38 +02:00
Thomas Waldmann cbeef56454 pyupgrade --py38-plus ./**/*.py 2022-02-27 20:11:56 +01:00
Milkey Mouse 47143cae76
Make timestamp helper timezone-aware 2020-11-05 01:27:46 -08:00
Henry-Joseph Audéoud b66533170a Forward the `format_spec` to `datetime` class
If specified, the argument `format_spec` is forwarded from the method
`OutputTimestamp.__format__` to the method `format_time` method.  Thus,
we are able to specify the format, in a way supported by the class
`datetime`.

The default behaviour of `format_time` is not affected.  The other parts
of code that does not provide a `format_spec` are not affected by the
change.
2018-08-29 14:00:57 +02:00
Thomas Waldmann 7996a87357 use safe parse_timestamp to parse timestamps, fixes #2994
also: refactor so it is possible to get tz-unaware datetime
objects from parse_timestamp.
2017-09-05 05:51:00 +02:00
Thomas Waldmann eebb117349 use ISO_FORMAT* constants 2017-09-05 05:02:44 +02:00
Marian Beermann ab4981eff6 always use microseconds for ISO 8601 output 2017-08-22 17:32:25 +02:00
Marian Beermann a836f451ab one datetime formatter to rule them all
# Conflicts:
#	src/borg/helpers.py
2017-08-22 17:32:21 +02:00
Thomas Waldmann 09c111bb44 archive listing: use iso8601 timestamp format with --json-lines
like yyyy-mm-ddThh:mm:ss - no tz yet, this likely needs more refactoring
to tz aware and utc datetime objects everywhere, currently there are
naive datetime objects and also localtime at quite some places.
2017-08-07 23:35:10 +02:00
Thomas Waldmann 3e78549f76 helpers: split into smaller modules 2017-08-07 23:05:46 +02:00