The method calculates a date inside the working time interval.
The date is calculated from the specified date and with the specified duration.
If a user is provided, the calculation will use the business calendar associated with that user.
Otherwise, the default calendar specified for the company as a whole will be used.
For example, you can calculate date within working hours will be 14 hours after the process start date:
const workingTime = await System.productionSchedule. calcDate(Context.data.__createdAt, new Duration(14, 'hours'));
Important: the time parameter must be a multiple of minutes.
The result is an object of the TDatetime type, with the same time zone as the input parameter from.
The method is used to get the duration of working time within a specified period.
The working hours duration is returned for the period
passed in the method’ s arguments.
If a user is provided, the calculation will use the business calendar associated with that user.
Otherwise, the default calendar specified for the company as a whole will be used.
Business calendar object
Used to get the settings of the business calendar, such as:
Hierarchy
Properties
Readonly specialCalendars
Object for working with calendars of exceptions.
Readonly workCalendars
Object for working with business calendars.
Methods
calcDate
The method calculates a date inside the working time interval.
The date is calculated from the specified date and with the specified duration. If a user is provided, the calculation will use the business calendar associated with that user. Otherwise, the default calendar specified for the company as a whole will be used. For example, you can calculate date within working hours will be 14 hours after the process start date:
const workingTime = await System.productionSchedule. calcDate(Context.data.__createdAt, new Duration(14, 'hours'));Important: the
timeparameter must be a multiple of minutes. The result is an object of theTDatetimetype, with the same time zone as the input parameterfrom.Parameters
from: TDatetime
time: number | TDuration
Optional user: TUser
Returns Promise<TDatetime>
deleteSpecialDays
Delete exceptions in the default business calendar.
Example of deleting short days and public holidays:
await System.productionSchedule.deleteSpecialDays([ new TDate(2023, 12, 31), new TDate(2023, 12, 30), ]);Parameters
dates: TDate[]
Returns Promise<void>
getGeneralSettings
The method returns the general settings of the business calendar.
General settings of the Business Calendar include work schedule and non- working days of the week.
const generalSettings = await System.productionSchedule.getGeneralSettings();Returns Promise<ProductionScheduleGeneralSettings>
getSpecialDays
The method gets short days and public holidays from the business calendar.
Sort days and public holidays are returned for a certain period specified
in the method's arguemnts:
Parameters
from: TDatetime | TDate
to: TDatetime | TDate
Returns Promise<ProductionScheduleSpecialDay[]>
getWorkingTime
The method is used to get the duration of working time within a specified period.
The working hours duration is returned for the period passed in the method’ s arguments. If a user is provided, the calculation will use the business calendar associated with that user. Otherwise, the default calendar specified for the company as a whole will be used.
Parameters
from: TDatetime
to: TDatetime
Optional user: TUser
Returns Promise<TDuration>
saveGeneralSettings
The method allows you to modify the general settings of the default business calendar, that is, the calendar specified in the company settings.
Example of editing the settings:
const settings = await System.productionSchedule.getGeneralSettings(); settings.weekends = { monday: false, tuesday: false, wednesday: false, thursday: false, friday: false, saturday: true, // Saturday is a non- working day sunday: true, // Sunday is a non-working day } await System.productionSchedule.saveGeneralSettings(settings);Parameters
settings: ProductionScheduleGeneralSettings
Returns Promise<void>
saveSpecialDays
Create or edit exceptions in the default business calendar.
Example of creating shortened and holiday days:
await System.productionSchedule.saveSpecialDays ([ // Shortened day { date: new TDate(2023, 12, 30), holiday: false, from: 16 * 60 * 60, // from 16:00 to: 18 * 60 * 60, // to 18:00 }, // Holiday { date: new TDate(2023, 12, 31), holiday: true, from: 0, to: 0, }, ]);Parameters
specialDays: ProductionScheduleSpecialDay[]
Returns Promise<void>
Feedback sent successfully
Thank you for your input