Skip to content

Commit

Permalink
Fixes #19228: Date format in search is French localised and the datep…
Browse files Browse the repository at this point in the history
…icker is broken
  • Loading branch information
fanf committed May 7, 2021
1 parent 074cb46 commit 9870980
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,16 +419,17 @@ final case object DateComparator extends LDAPCriterionType {
override val comparators = OrderedComparators.comparators.filterNot( c => c == Regex || c == NotRegex)
val fmt = "dd/MM/yyyy"
val frenchFmt = DateTimeFormat.forPattern(fmt).withLocale(Locale.FRANCE)
def error(value: String, e: Exception) = Inconsistency(s"Invalide date: '${value}', expected format is: '${fmt}'. Error was: ${e.getMessage}")

override protected def validateSubCase(v:String,comparator:CriterionComparator) = try {
Right(frenchFmt.parseDateTime(v).toString)
} catch {
case e:Exception =>
Left(Inconsistency(s"Invalide date: '${v}'. Error was: ${e.getMessage}"))
Left(error(v, e))
}
//init a jquery datepicker
override def initForm(formId:String) : JsCmd = OnLoad(JsRaw(
"""var init = $.datepicker.regional['en-GB'];
"""var init = $.datepicker.regional['en'];
init['showOn'] = 'focus';
$('#%s').datepicker(init);
""".format(formId)))
Expand All @@ -441,7 +442,7 @@ final case object DateComparator extends LDAPCriterionType {
Right(date)
} catch {
case e:Exception =>
Left(Inconsistency(s"Invalide date: '${value}'. Error was: ${e.getMessage}"))
Left(error(value, e))
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
, changeYear: true
, showButtonPanel: true
});
$.datepicker.setDefaults( $.datepicker.regional[ "en-GB" ] );
$.datepicker.setDefaults( $.datepicker.regional[ "en" ] );
};

// ]]>
Expand Down

0 comments on commit 9870980

Please sign in to comment.