From 682d6f9dd71dae2e5f56f6e0f9f71d1e9230db33 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 21 Sep 2023 12:33:15 -0700 Subject: [PATCH] + (Core) Updated the Date picker to show the current date using Rock time, instead of the date of the local machine. (Fixes #2543) --- Rock/Web/UI/Controls/Pickers/DatePicker.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Rock/Web/UI/Controls/Pickers/DatePicker.cs b/Rock/Web/UI/Controls/Pickers/DatePicker.cs index 76606247a6d..95f1ff9c007 100644 --- a/Rock/Web/UI/Controls/Pickers/DatePicker.cs +++ b/Rock/Web/UI/Controls/Pickers/DatePicker.cs @@ -210,18 +210,19 @@ private void RegisterJavascript() // Get current date format and make sure it has double-lower-case month and day designators for the js date picker to use var dateFormat = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern; - dateFormat = dateFormat.Replace( "M", "m" ).Replace( "m", "mm" ).Replace( "mmmm", "mm" ); - dateFormat = dateFormat.Replace( "d", "dd" ).Replace( "dddd", "dd" ); + var jsDateFormat = dateFormat.Replace( "M", "m" ).Replace( "m", "mm" ).Replace( "mmmm", "mm" ); + jsDateFormat = jsDateFormat.Replace( "d", "dd" ).Replace( "dddd", "dd" ); - var endDateParam = ( this.AllowFutureDateSelection ) ? "" : "endDate: '" + RockDateTime.Today.ToString( "o" ) + "',"; - var startDateParam = ( this.AllowPastDateSelection ) ? "" : "startDate: '" + RockDateTime.Today.ToString( "o" ) + "',"; + // StartDate and EndDate are optional, and must match the format of the dateFormat (which is the format of the input) + var endDateParam = ( this.AllowFutureDateSelection ) ? "" : "endDate: '" + RockDateTime.Today.ToString( dateFormat ) + "',"; + var startDateParam = ( this.AllowPastDateSelection ) ? "" : "startDate: '" + RockDateTime.Today.ToString( dateFormat ) + "',"; var script = $@"Rock.controls.datePicker.initialize( {{ id: '{this.ClientID}', startView: {this.StartView.ConvertToInt()}, showOnFocus: {this.ShowOnFocus.ToString().ToLower()}, - format: '{dateFormat}', + format: '{jsDateFormat}', todayHighlight: {this.HighlightToday.ToString().ToLower()}, forceParse: {this.ForceParse.ToString().ToLower()}, postbackScript: '{postBackScript}',