util-lib: make timestamp generation and parsing reversible (#3869)

This patch improves parsing and generation of timestamps and calendar
specifications in two ways:

- The week day is now always printed in the abbreviated English form, instead
  of the locale's setting. This makes sure we can always parse the week day
  again, even if the locale is changed. Given that we don't follow locale
  settings for printing timestamps in any other way either (for example, we
  always use 24h syntax in order to make uniform parsing possible), it only
  makes sense to also stick to a generic, non-localized form for the timestamp,
  too.

- When parsing a timestamp, the local timezone (in its DST or non-DST name)
  may be specified, in addition to "UTC". Other timezones are still not
  supported however (not because we wouldn't want to, but mostly because libc
  offers no nice API for that). In itself this brings no new features, however
  it ensures that any locally formatted timestamp's timezone is also parsable
  again.

These two changes ensure that the output of format_timestamp() may always be
passed to parse_timestamp() and results in the original input. The related
flavours for usec/UTC also work accordingly. Calendar specifications are
extended in a similar way.

The man page is updated accordingly, in particular this removes the claim that
timestamps systemd prints wouldn't be parsable by systemd. They are now.

The man page previously showed invalid timestamps as examples. This has been
removed, as the man page shouldn't be a unit test, where such negative examples
would be useful. The man page also no longer mentions the names of internal
functions, such as format_timestamp_us() or UNIX error codes such as EINVAL.
7 files changed
tree: 24f423af1ad97cb24fdce4f1feb17797af99a529
  1. .github/
  2. catalog/
  3. coccinelle/
  4. docs/
  5. factory/
  6. hwdb/
  7. m4/
  8. man/
  9. network/
  10. po/
  11. rules/
  12. shell-completion/
  13. src/
  14. sysctl.d/
  15. system-preset/
  16. sysusers.d/
  17. test/
  18. tmpfiles.d/
  19. tools/
  20. units/
  21. xorg/
  22. .dir-locals.el
  23. .editorconfig
  24. .gitattributes
  25. .gitignore
  26. .mailmap
  27. .travis.yml
  28. .vimrc
  29. .ycm_extra_conf.py
  30. autogen.sh
  31. CODING_STYLE
  32. configure.ac
  33. DISTRO_PORTING
  34. HACKING
  35. LICENSE.GPL2
  36. LICENSE.LGPL2.1
  37. Makefile-man.am
  38. Makefile.am
  39. mkosi.build
  40. mkosi.default
  41. NEWS
  42. README
  43. README.md
  44. TODO
README.md

systemd - System and Service Manager

Build Status
Coverity Scan Status

Details

General information about systemd can be found in the systemd Wiki.

Information about build requirements are provided in the README file.

Consult our NEWS file for information about what's new in the most recent systemd versions.

Please see the HACKING file for information how to hack on systemd and test your modifications.

Please see our Contribution Guidelines for more information about filing GitHub Issues and posting GitHub Pull Requests.

When preparing patches for systemd, please follow our Coding Style Guidelines.

If you are looking for support, please contact our mailing list or join our IRC channel.