summaryrefslogtreecommitdiff
path: root/src/basic/calendarspec.c
AgeCommit message (Collapse)Author
2017-02-12calendarspec: fix duplicate detection (#5310)Doug Christman
a2eb5ea79c added a new field to `CalendarComponent`; update `normalize_chain` to compare all fields when dropping duplicates
2017-02-02time-util: refuse formatting/parsing times that we can't storeLennart Poettering
usec_t is always 64bit, which means it can cover quite a number of years. However, 4 digit year display and glibc limitations around time_t limit what we can actually parse and format. Let's make this explicit, so that we never end up formatting dates we can#t parse and vice versa. Note that this is really just about formatting/parsing. Internal calculations with times outside of the formattable range are not affected.
2017-02-02time: time_t is signed, and mktime() is happy to return negative timeLennart Poettering
Passing a year such as 1960 to mktime() will result in a negative return value. This is quite confusing, as the man page claims that on failure the call will return -1... Given that our own usec_t type is unsigned, and we can't express times before 1970 hence, let's consider all negative times returned by mktime() as invalid, regardless if just -1, or anything else negative.
2016-12-20calendarspec: minor refactoring and style fixDouglas Christman
2016-12-20calendarspec: improve overflow handlingDouglas Christman
Check if the parsed seconds value fits in an integer *after* multiplying by USEC_PER_SEC, otherwise a large value can trigger modulo by zero during normalization.
2016-12-16calendarspec: remove superfluous variablesDouglas Christman
2016-12-16calendarspec: rename fields of CalendarComponentDouglas Christman
value/range_end -> start/stop
2016-12-16calendarspec: allow repetition values with rangesDouglas Christman
"Every other hour from 9 until 5" can be written as `9..17/2:00` instead of `9,11,13,15,17:00`
2016-12-14calendarspec: free memory when parsing fails (#4890)Doug Christman
This prevents memory leaks on strings like `*~*-*`. Fixes #4887
2016-12-06calendarspec: always interpret missing seconds as :00 (#4813)Doug Christman
"*:*" should be equivalent to "*-*-* *:*:00" (minutely) rather than running every microsecond. Fixes #4804
2016-11-25calendarspec: refactor format_chain()Douglas Christman
Factor out repeated references to usec and remove nested ifs.
2016-11-24calendarspec: rename "eom" to "end_of_month"Douglas Christman
2016-11-24calendarspec: make specifications with ranges reversibleDouglas Christman
"*-*-01..03" is now formatted as "*-*-01..03" instead of "*-*-01,02,03"
2016-11-24calendarspec: allow whole second rangesDouglas Christman
Previously a string like "00:00:01..03" would fail to parse due to the ambiguity between a decimal point and the start of a range.
2016-11-24calendarspec: make specifications with seconds wildcard reversibleDouglas Christman
"*:*:*" is now formatted as "*:*:*" instead of "*:*:00/1"
2016-11-24calendarspec: reject strings with spurious spaces and signsDouglas Christman
strtoul() parses leading whitespace and an optional sign; check that the first character is a digit to prevent odd specifications like "00: 00: 00" and "-00:+00/-1".
2016-11-24calendarspec: reject open weekday rangesDouglas Christman
Forbid open ranges like "Tue.."; trailing commas are still OK.
2016-11-24calendarspec: reject strings that only contain a timezoneDouglas Christman
This makes " UTC" an illegal date specification.
2016-11-24calendarspec: always interpret a missing time as 00:00:00Douglas Christman
"*-*-*" is now equivalent to "*-*-* 00:00:00" (daily) rather than "*-*-* *:*:*" (every second).
2016-11-23calendarspec: add support for scheduling timers at the end of the monthDouglas Christman
"*-*~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-23calendarspec: add upper bound on yearDouglas Christman
Stop looking for matches after MAX_YEAR so impossible dates like "*-02-30" and "*-04-31" don't cause an infinite loop.
2016-08-03util-lib: make timestamp generation and parsing reversible (#3869)Lennart Poettering
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-07-01calendarspec: use ".." notation for ranges of weekdaysDouglas Christman
For backwards compatibility, both the new format (Mon..Wed) and the old format (Mon-Wed) are supported.
2016-07-01calendarspec: allow ranges in date and time specificationsDouglas Christman
Resolves #3042
2016-02-23tree-wide: minor formatting inconsistency cleanupsVito Caputo
2016-02-22tree-wide: make ++/-- usage consistent WRT spacingVito Caputo
Throughout the tree there's spurious use of spaces separating ++ and -- operators from their respective operands. Make ++ and -- operator consistent with the majority of existing uses; discard the spaces.
2016-02-22calendarspec: fix find_next skipping timesHristo Venev
reset usec when bumping hours/minutes
2016-02-21util-lib: fix returned error codeLennart Poettering
Make sure we propagate errors properly.
2016-02-21util-lib: add (void) cast to indicate that we don't care about the ↵Lennart Poettering
normalization success After all, we verify that every calendar part is not out of bounds later on, and it's fully OK if the normalization has no effect.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-12-01basic: re-sort includesThomas Hindoe Paaboel Andersen
My previous patch to only include what we use accidentially placed the added inlcudes in non-sorted order.
2015-11-30basic: include only what we useThomas Hindoe Paaboel Andersen
This is a cleaned up result of running iwyu but without forward declarations on src/basic.
2015-11-17calendarspec: sub-second support, v3Hristo Venev
2015-11-16tree-wide: sort includesThomas Hindoe Paaboel Andersen
Sort the includes accoding to the new coding style.
2015-11-10time-util: add parse_time(), which is like parse_sec() but allows ↵Lennart Poettering
specification of default time unit if none is specified This is useful if we want to parse RLIMIT_RTTIME values where the common UNIX syntax is without any units but refers to a non-second unit (µs in this case), but where we want to allow specification of units.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: move more file I/O related calls into fileio.[ch]Lennart Poettering
2015-10-25basic: use the return value of endswithHristo Venev
It returns the position where the suffix begins, which can be used for strndup to extract the prefix without calling strlen.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
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-15basic: calendarspec UTC supportHristo Venev
Just add " UTC" to the end of the event expression. Works for the special expressions.
2015-07-29tree-wide: port everything over to fflush_and_check()Lennart Poettering
Some places invoked fflush() directly with their own manual error checking, let's unify all that by using fflush_and_check(). This also unifies the general error paths of fflush()+rename() file writers.
2015-06-11build-sys: split internal basic/ library from shared/Kay Sievers
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/