X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=ang%2FcrmMailing%2FRadioDate.js;h=037b6e22ba9695e2988bd79b4d26617e1b331700;hb=179cb5e37a971a2666d80918c072852ee00babd5;hp=c747f2e275f2673000a3ace185a88aa296b94268;hpb=d5e5f8438fe2777954f815731e1422c367624bea;p=civicrm-core.git diff --git a/ang/crmMailing/RadioDate.js b/ang/crmMailing/RadioDate.js index c747f2e275..037b6e22ba 100644 --- a/ang/crmMailing/RadioDate.js +++ b/ang/crmMailing/RadioDate.js @@ -1,10 +1,24 @@ (function(angular, $, _) { + // "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; + } + // Represent a datetime field as if it were a radio ('schedule.mode') and a datetime ('schedule.datetime'). // example: