fnStrToDate function

dynamic fnStrToDate(
  1. dynamic value
)

Expression function StrToDate(s): Converts a string to a date. In this Dart engine it returns a date serial number (days since 1899-12-30); see the manual, Appendix C.2.

Implementation

dynamic fnStrToDate(dynamic value) {
  var s = varToStr(value).replaceAll("/", "-");
  final dt = DateTime.tryParse(s);
  if (dt == null) return null;
  // Takes only the date portion, zeroing the time, so that if the string
  // carries a time component it doesn't get counted into the fractional part.
  return _toDelphiSerial(DateTime(dt.year, dt.month, dt.day));
}