Skip to content

Commit

Permalink
+ (Core) Updated the Date picker to show the current date using Rock …
Browse files Browse the repository at this point in the history
…time, instead of the date of the local machine. (Fixes #2543)
  • Loading branch information
garrettjohnson committed Sep 21, 2023
1 parent 21e3e55 commit 682d6f9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Rock/Web/UI/Controls/Pickers/DatePicker.cs
Expand Up @@ -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}',
Expand Down

0 comments on commit 682d6f9

Please sign in to comment.