+ // "YYYY-MM-DD hh:mm:ss" => Date()
+ function parseYmdHms(d) {
+ var parts = d.split(/[\-: ]/);
+ return new Date(parts[0], parts[1]-1, parts[2], parts[3], parts[4], parts[5]);
+ }
+
+ function isDateBefore(tgt, cutoff, tolerance) {
+ var ad = parseYmdHms(tgt), bd = parseYmdHms(cutoff);
+ // We'll allow a little leeway, where tgt is considered before cutoff
+ // even if technically misses the cutoff by a little.
+ return ad < bd-tolerance;
+ }
+