- /* We don't know which day until we get an event. */
- result_bound->lazy_values.hh = hh;
- result_bound->lazy_values.mm = mm;
- result_bound->lazy_values.ss = ss;
- result_bound->lazy_values.ns = ns;
- result_bound->lazy_values.gmt = gmt;
- goto lazy;
+ if (!trimmer->date) {
+ /* We don't know which day until we get an event. */
+ result_bound->lazy_values.hh = hh;
+ result_bound->lazy_values.mm = mm;
+ result_bound->lazy_values.ss = ss;
+ result_bound->lazy_values.ns = ns;
+ result_bound->lazy_values.gmt = gmt;
+ goto lazy;
+ } else {
+ struct tm tm = {
+ .tm_sec = ss,
+ .tm_min = mm,
+ .tm_hour = hh,
+ .tm_mday = trimmer->day,
+ .tm_mon = trimmer->month - 1,
+ .tm_year = trimmer->year - 1900,
+ .tm_isdst = -1,
+ };
+ time_t result;
+
+ if (gmt) {
+ result = timegm(&tm);
+ if (result < 0) {
+ return -1;
+ }
+ } else {
+ result = mktime(&tm);
+ if (result < 0) {
+ return -1;
+ }
+ }
+ value = (int64_t) result;
+ value *= NSEC_PER_SEC;
+ value += ns;
+ goto set;
+ }