1) Apply Datetime Offset :
private void applyDateTimeOffset(
FieldId _fieldId,
TransDate _baseDate,
int _dateOffset,
RORDateUnit _dateUnit,
boolean _applyDateOffset,
TimeOfDay _baseTime,
int _timeOffset,
RORTimeUnit _timeUnit,
boolean _applyTimeOffset,
boolean _hasSystemTime = false)
{
int timeZoneDifference = (DateTimeUtil::time(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone()))
- DateTimeUtil::time(DateTimeUtil::getSystemDateTime()));
TransDate rentDate = DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(this.(_fieldId), DateTimeUtil::getUserPreferredTimeZone()));
TimeOfDay rentTime = DateTimeUtil::time(this.(_fieldId)) + timeZoneDifference;
if (_applyDateOffset)
{
rentDate = RORRentalDateTimes::applyDateOffset(_baseDate, _dateOffset, _dateUnit);
}
if (_applyTimeOffset)
{
rentTime = RORRentalDateTimes::applyTimeOffset(_baseTime, _timeOffset, _timeUnit);
}
if (!rentDate && _hasSystemTime)
{
rentTime = rentTime + timeZoneDifference;
}
this.(_fieldId) = _hasSystemTime ? DateTimeUtil::newDateTime(rentDate, rentTime) : DateTimeUtil::newDateTime(rentDate, rentTime, DateTimeUtil::getUserPreferredTimeZone());
this.modifiedField(_fieldId);
}
private void applyDateTimeOffset(
FieldId _fieldId,
TransDate _baseDate,
int _dateOffset,
RORDateUnit _dateUnit,
boolean _applyDateOffset,
TimeOfDay _baseTime,
int _timeOffset,
RORTimeUnit _timeUnit,
boolean _applyTimeOffset,
boolean _hasSystemTime = false)
{
int timeZoneDifference = (DateTimeUtil::time(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone()))
- DateTimeUtil::time(DateTimeUtil::getSystemDateTime()));
TransDate rentDate = DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(this.(_fieldId), DateTimeUtil::getUserPreferredTimeZone()));
TimeOfDay rentTime = DateTimeUtil::time(this.(_fieldId)) + timeZoneDifference;
if (_applyDateOffset)
{
rentDate = RORRentalDateTimes::applyDateOffset(_baseDate, _dateOffset, _dateUnit);
}
if (_applyTimeOffset)
{
rentTime = RORRentalDateTimes::applyTimeOffset(_baseTime, _timeOffset, _timeUnit);
}
if (!rentDate && _hasSystemTime)
{
rentTime = rentTime + timeZoneDifference;
}
this.(_fieldId) = _hasSystemTime ? DateTimeUtil::newDateTime(rentDate, rentTime) : DateTimeUtil::newDateTime(rentDate, rentTime, DateTimeUtil::getUserPreferredTimeZone());
this.modifiedField(_fieldId);
}
=======================================================================
2) Check whether current date time exists in active calendar :
private boolean checkDateCalendar(FieldId _fieldId, CalendarId _calendarId = '')
{
boolean ret = true;
CalendarId calendarId = _calendarId;
WorkCalendarDate workCalendarDate;
TransDate rentalDate = DateTimeUtil::date(this.(_fieldId));
Query query;
SysInfoAction_FormrunQuery infoAction;
;
if (rentalDate
&& this.RORRentalDateTimesHost::isWorksheetTable()
&& this.hostHeadingLineLevel() == HeadingLine::Line)
{
if (!calendarId)
{
calendarId = this.getHostBuffer().calendarId;
}
if (calendarId)
{
workCalendarDate = WorkCalendarDate::RORfind(calendarId, rentalDate);
if (!workCalendarDate)
{
query = new Query();
query.addDataSource(tablenum(WorkCalendarTable)).addRange(fieldnum(WorkCalendarTable, CalendarId)).value(queryValue(calendarId)) ;
infoAction = SysInfoAction_FormrunQuery::newFormnameQuery(formstr(WorkCalendarTable), query);
ret = checkFailed(strFmt("@DNR3262", calendarId, rentalDate), '', infoAction);
}
}
}
return ret;
}
private boolean checkDateCalendar(FieldId _fieldId, CalendarId _calendarId = '')
{
boolean ret = true;
CalendarId calendarId = _calendarId;
WorkCalendarDate workCalendarDate;
TransDate rentalDate = DateTimeUtil::date(this.(_fieldId));
Query query;
SysInfoAction_FormrunQuery infoAction;
;
if (rentalDate
&& this.RORRentalDateTimesHost::isWorksheetTable()
&& this.hostHeadingLineLevel() == HeadingLine::Line)
{
if (!calendarId)
{
calendarId = this.getHostBuffer().calendarId;
}
if (calendarId)
{
workCalendarDate = WorkCalendarDate::RORfind(calendarId, rentalDate);
if (!workCalendarDate)
{
query = new Query();
query.addDataSource(tablenum(WorkCalendarTable)).addRange(fieldnum(WorkCalendarTable, CalendarId)).value(queryValue(calendarId)) ;
infoAction = SysInfoAction_FormrunQuery::newFormnameQuery(formstr(WorkCalendarTable), query);
ret = checkFailed(strFmt("@DNR3262", calendarId, rentalDate), '', infoAction);
}
}
}
return ret;
}
(or)
private static boolean dateIsOpen(CalendarId _calendarId, TransDate _transDate, workCalendarSched _workCalendarSched = null)
{
WorkCalendarSched workCalendarSched = _workCalendarSched ? _workCalendarSched : new WorkCalendarSched(true);
;
return workCalendarSched.isDateOpen(_calendarId, _transDate);
}
No comments:
Post a Comment