Commit graph

16 commits

Author SHA1 Message Date
Douglas Christman 8ea803516e calendarspec: add support for scheduling timers at the end of the month
"*-*~1"       => The last day of every month
"*-02~3..5"   => The third, fourth, and fifth last days in February
"Mon 05~07/1" => The last Monday in May

Resolves #3861
2016-11-23 12:37:43 -05:00
Douglas Christman f6e7d66b9f calendarspec: add upper bound on year
Stop looking for matches after MAX_YEAR so impossible dates like
"*-02-30" and "*-04-31" don't cause an infinite loop.
2016-11-23 12:28:00 -05:00
Evgeny Vereshchagin a5d5c0d2df tests: fix memleak in test-calendarspec (#4424)
Fixes:
```
==10750==
==10750== HEAP SUMMARY:
==10750==     in use at exit: 96 bytes in 3 blocks
==10750==   total heap usage: 1,711 allocs, 1,708 frees, 854,545 bytes
allocated
==10750==
==10750== 96 (64 direct, 32 indirect) bytes in 1 blocks are definitely
lost in loss record 3 of 3
==10750==    at 0x4C2DA60: calloc (vg_replace_malloc.c:711)
==10750==    by 0x4EB3BDA: calendar_spec_from_string
(calendarspec.c:771)
==10750==    by 0x109675: test_hourly_bug_4031 (test-calendarspec.c:118)
==10750==    by 0x10A00E: main (test-calendarspec.c:202)
==10750==
==10750== LEAK SUMMARY:
==10750==    definitely lost: 64 bytes in 1 blocks
==10750==    indirectly lost: 32 bytes in 2 blocks
==10750==      possibly lost: 0 bytes in 0 blocks
==10750==    still reachable: 0 bytes in 0 blocks
==10750==         suppressed: 0 bytes in 0 blocks
==10750==
==10750== For counts of detected and suppressed errors, rerun with: -v
==10750== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
```
2016-10-20 17:44:30 +02:00
Zbigniew Jędrzejewski-Szmek 250517d2d3 test-calendarspec: test that hourly timers are incremented properly
Apparently this works just fine, so the issue in #4031 is elsewhere.
2016-10-17 00:08:43 -04:00
Lennart Poettering 21b3a0fcd1 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.
2016-08-03 19:04:53 -04:00
Douglas Christman e638d0504f calendarspec: use ".." notation for ranges of weekdays
For backwards compatibility, both the new format (Mon..Wed) and
the old format (Mon-Wed) are supported.
2016-07-01 23:13:58 -04:00
Douglas Christman 32b5236916 calendarspec: allow ranges in date and time specifications
Resolves #3042
2016-07-01 23:13:58 -04:00
Hristo Venev a022d76e6a calendarspec: fix find_next skipping times
reset usec when bumping hours/minutes
2016-02-22 08:02:48 -05:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Hristo Venev f22554a06d test: calendarspec sub-second tests 2015-11-17 23:52:09 +02:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Hristo Venev 9d5bd70d9e test: add calendarspec UTC tests 2015-10-15 02:58:00 +03:00
Lennart Poettering dbfd41e2df calendarspec: parse 'quarterly' and 'semi-annually' as shortcuts 2014-10-27 18:09:26 +01:00
Lennart Poettering aaa870928f test: extend calendarspec test a bit 2012-11-23 21:50:51 +01:00
Lennart Poettering 36697dc019 timer: implement calendar time events 2012-11-23 21:37:58 +01:00