Skip to content

SAK-51264 Calendar fix date errors and datepicker errors #13555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4649,7 +4649,6 @@ public void doNew(RunData data, Context context)
state.setState(STATE_NEW);
state.setCalendarEventId("", "");
state.setIsNewCalendar(true);
state.setIsPastAlertOff(true);
sstate.setAttribute(FREQUENCY_SELECT, null);
sstate.setAttribute(CalendarAction.SSTATE__RECURRING_RULE, null);

Expand Down Expand Up @@ -4827,18 +4826,6 @@ else if(hour.equals("100") || minute.equals("100")) {

state.setNewData(calId, title,description,Integer.parseInt(month),Integer.parseInt(day),year,houri,Integer.parseInt(minute),Integer.parseInt(dhour),Integer.parseInt(dminute),type,timeType,location, addfieldsMap, intentionStr);
state.setState(STATE_NEW);
}
else if( event_startTime.before(now_time) && state.getIsPastAlertOff() ) {
// IsPastAlertOff
// true: no alert shown -> then show the alert, set false;
// false: Alert shown, if user click ADD - doAdd again -> accept it, set true, set alert empty;

String errorCode = rb.getString("java.alert.past");
addAlert(sstate, errorCode);

state.setNewData(state.getPrimaryCalendarReference(), title,description,Integer.parseInt(month),Integer.parseInt(day),year,houri,Integer.parseInt(minute),Integer.parseInt(dhour),Integer.parseInt(dminute),type,timeType,location, addfieldsMap, intentionStr);
state.setState(STATE_NEW);
state.setIsPastAlertOff(false);
} else if (!DateFormatterUtil.checkDate(Integer.parseInt(day), Integer.parseInt(month), Integer.parseInt(year))) {
addAlert(sstate, rb.getString("date.invalid"));
state.setNewData(state.getPrimaryCalendarReference(), title,description,Integer.parseInt(month),Integer.parseInt(day),year,houri,Integer.parseInt(minute),Integer.parseInt(dhour),Integer.parseInt(dminute),type,timeType,location, addfieldsMap, intentionStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ public class CalendarActionState

private String m_AttachmentFlag = "false";
private LocalEvent savedData = new LocalEvent();
private boolean m_IsPastAlertOff = true;


private String m_state = "";
private String currentpage = "second";
Expand Down Expand Up @@ -213,16 +211,6 @@ public void setIsNewCalendar(boolean isNewcal)

} // setIsNewCalendar

/**
* Get the status of past alert off: true - no alert shown; false - alert shown
* @return IsPastAlertOff
*/
public boolean getIsPastAlertOff()
{
return m_IsPastAlertOff;

} // getIsPastAlertOff

/**
* Gets the main calendar ID associated with the event list. Many calendars may be merged into this list, but there is only one one calendar that is used for adding/modifying events.
*/
Expand All @@ -231,16 +219,6 @@ public String getPrimaryCalendarReference()
return m_primaryCalendarReference;
}

/**
* Set the status of past alert off: true - no alert shown; false - alert shown
* @param IsPastAlertOff The status of past alert off: true - no alert shown; false - alert shown
*/
public void setIsPastAlertOff(boolean IsPastAlertOff)
{
m_IsPastAlertOff = IsPastAlertOff;

} // setIsPastAlertOff

/**
* Sets the main calendar ID associated with the event list. Many calendars may be merged into this
* list, but there is only one one calendar that is used for adding/modifying events/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,17 @@ $(function() {
#set($day=$date.getDay())
#set($year=$todayYear)
#end
<input type="text" id="newCalendarDate" name="newCalendarDate" class="datepicker" value="">
<input type="text" id="newCalendarDate" name="newCalendarDate" class="datepicker">
<script type="text/javascript">
localDatePicker({
input:'#newCalendarDate',
useTime:0,
val:"$year$H$month$H$day",
val:"${year}-${month}-${day}",
parseFormat: 'YYYY-MM-DD',
ashidden:{
month:"month",
day:"day",
year:"yearSelect",
iso8601: 'newCalendarDateISO8601'
}
});
</script>
Expand Down
12 changes: 8 additions & 4 deletions library/src/webapp/js/lang-datepicker/lang-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ const defaults = {
const [datePart, timePart] = value.split('T');
const [year, month, day] = datePart.split('-').map(Number);
const timeComponents = timePart.split(':').map(Number);

}

// Handle simple YYYY-MM-DD format
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
const [year, month, day] = value.split('-').map(Number);
if (!isNaN(year) && !isNaN(month) && !isNaN(day)) {
const d = new Date();
d.setFullYear(year);
d.setMonth(month - 1);
d.setMonth(month - 1); // JS months are 0-indexed
d.setDate(day);
d.setHours(timeComponents[0] || 0);
d.setMinutes(timeComponents[1] || 0);
d.setHours(0); // Explicitly set time to midnight local
d.setMinutes(0);
d.setSeconds(0);
d.setMilliseconds(0);
return d;
Expand Down
Loading