mktime method

int mktime(
  1. Tm timeptr
)

Converts a local Tm structure to a Unix timestamp (time_t). This also normalizes the values in timeptr.

Implementation

int mktime(Tm timeptr) {
  final dt = timeptr.toDateTime(isUtc: false);
  final normalized = Tm.fromDateTime(dt);
  timeptr.tm_sec = normalized.tm_sec;
  timeptr.tm_min = normalized.tm_min;
  timeptr.tm_hour = normalized.tm_hour;
  timeptr.tm_mday = normalized.tm_mday;
  timeptr.tm_mon = normalized.tm_mon;
  timeptr.tm_year = normalized.tm_year;
  timeptr.tm_wday = normalized.tm_wday;
  timeptr.tm_yday = normalized.tm_yday;
  timeptr.tm_isdst = normalized.tm_isdst;
  return dt.millisecondsSinceEpoch ~/ 1000;
}