Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

This

...

class

...

methods are designed to work with the SimpleSchedule objects. You can use them, for example, to get a schedule name, to verify if the current time

...

matches with the working time, and return the difference between the two time values.

SimpleSchedule(id, timezoneTitle)


Use this cinstructor to instantiate a new SimpleSchedule object.


Parameter(s):

NameTypeMandatoryDefault Value
idStringNN
timezoneTitleStringN'UTC'


Example:

Code Block
languagejs
themeEclipse
titleSimpleSchedule
linenumberstrue
const schedule = new SimpleSchedule('157165292607666710', 'UTC');


duration(startDateTime, endDateTime

...

)


This method determines

...

the time

...

difference in the schedule between two

...

SimpleDateTime values,

...

based on the schedule time zone or, if not specified,

...

the session time zone.


Note

The passed SimpleDateTime value should be in the schedule. For verification, use the isInSchedule(datetime) method.


Parameter(s):

NameTypeMandatoryDefault Value

...

startDateTimeSimpleDateTime object

...

YN
endDateTimeSimpleDateTimeYN


Return:

TypeDescription
SimpleDurationThe difference between the two time values

...

.


Example:

Code Block
languagejs
titleduration

...

const 

...

startDatetime = new SimpleDateTime('

...

2022-

...

01-25 08:00:00');

...

const 

...

endDatetime = new SimpleDateTime('

...

2022-

...

01-29 08:00:00');

...

const 

...

schedule = new SimpleSchedule('

...

161050499417811121'

...

); 

...

// sys_schedule.sys_id
const duration = 

...

schedule.duration(

...

startDatetime, 

...

endDatetime);
ss.info(duration.getValue());

...

load(sysId, timeZone)

Parameter(s):

 // Info: 1970-01-02 08:00:00

getName()


This method returns the name of the defined schedule.

...


Return:

TypeDescription
StringThe schedule name.


Example:

Code Block

...

language

...

Описание: Инициализирует расписание по sys_id.

Принимает: sysId - integer; (опционально) timeZone - string (по умолчанию - пустая строка).
Возвращает: Ничего.

Пример:

let simple_schedule = new SimpleSchedule();

simple_schedule.load('1');

...

Описание: Возвращает имя расписания.

Принимает: Ничего.
Возвращает: string.

Пример:

let simple_schedule = new SimpleSchedule('1', 'Europe/Moscow');
ss.info(simple_schedule.getName());

...

Описание: Проверяет, есть ли записи для выбранного расписания.

Принимает: Ничего.
Возвращает: boolean.

Пример:

let simple_schedule = new SimpleSchedule('1', 'Europe/Moscow');
ss.info(simple_schedule.isValid());

...

Описание: Определяет, находится ли данное время в текущем расписании.

Принимает: SimpleDateTime.

Возвращает: boolean.

Пример:

let time = new SimpleDateTime();
let simple_schedule = new SimpleSchedule('1', 'Europe/Moscow');
ss.info(simple_schedule.isInSchedule(time));

...

Описание: Определяет, является время рабочим или нет.

Принимает: SimpleDateTime.
Возвращает: boolean.

Пример:

let time = new SimpleDateTime();
let simple_schedule = new SimpleSchedule('1', 'Europe/Moscow');
ss.info(simple_schedule.isWorkingTime(time));

Не выносить в документацию

...

Описание: Устанавливает тайм-зону.

Принимает: string.
Возвращает: Ничего.

Пример:

...

js
titlegetName
const schedule = new SimpleSchedule('157165292607666710');
ss.info(schedule.getName()); // Info: 8x5 excluding Russian Holidays

isInSchedule(datetime)


This method checks whether the current schedule includes the given datetime or they do not match.


Info

Excluded schedule segments will also return 'true' within checking by this method.


Parameter(s):

NameTypeMandatoryDefault Value
datetimeSimpleDateTimeYN


Return:

TypeDescription
BooleanThis method returns 'true' if the specified datetime is in schedule; otherwise, it returns 'false'.


Example:

Code Block
languagejs
titleisInSchedule
const nowDatetime = new SimpleDateTime();
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
ss.info(schedule.isInSchedule(nowDatetime)); // Info: false

isValid()


The method checks if the specified SimpleSchedule object is valid.

Info

The object is considered as invalid when:

  1. The schedule passed does not exist.
  2. The schedule does not contain schedule elements of the working type. The example type for elements of such schedule is Time Off or Excluded.

In both cases above, the isValid() method returns 'false'.


Return:

TypeDescription
BooleanThis method returns 'true' if the schedule is valid; otherwise, it returns 'false'.

Example:

Code Block
languagejs
titleisValid
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
ss.info(schedule.isValid()); // Info: true

isWorkingTime(datetime)


This method checks whether a provided date and time is a working time or not.


Parameter(s):

NameTypeMandatoryDefault Value
datetimeSimpleDateTimeYN


Return:

TypeDescription
BooleanThis method returns 'true' if provided date and time is a working time; otherwise, it returns 'false'.


Code Block
languagejs
themeEclipse
titleisWorkingTime
linenumberstrue
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
const firstDatetime = new SimpleDateTime('2020-12-15 05:59:59');
const secondDatetime = new SimpleDateTime('2020-12-15 06:00:00');
ss.info(schedule.isWorkingTime(firstDatetime)); // Info: false
ss.info(schedule.isWorkingTime(secondDatetime)); // Info: true

load(sysId, timezoneTitle)


This method initializes a schedule specified with the sys_id.


Parameter(s):

NameTypeMandatoryDefault Value
sysIdStringYN
timezoneTitleString (empty string by default)N''


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titleload
const schedule = new SimpleSchedule();
schedule.load('157165292607666710'); // sys_schedule.sys_id

setTimeZone(timezoneTitle)


This method defines which time zone is to be applied to the current schedule.


Parameter(s):

NameTypeMandatoryDefault Value
timezoneTitleStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titlesetTimeZone
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
schedule.setTimeZone('US/Central');

...

whenNext(

...

datetime,

...

Описание: Определяет, когда истекает указанное рабочее время.

Принимает:startDate - SimpleDateTime, finalWorkingSeconds - integer
Возвращает: false|string.

Пример:

let startDate = new SimpleDateTime('2019-10-25 08:00:00');
let finalWorkingSeconds = 12345;
let simple_schedule = new SimpleSchedule('1', 'Europe/Moscow');
ss.info(simple_schedule.whenWillExpire(startDate, finalWorkingSeconds));

timezoneTitle)


This method returns the number of seconds left until the next schedule element starts.


Parameter(s):

NameTypeMandatoryDefault Value
datetimeSimpleDateTimeYN
timezoneTitle

String

N''


Return:

TypeDescription
SimpleDurationThe SimpleDuration object.


Example:

Code Block
languagejs
themeEclipse
titlewhenNext
linenumberstrue
const startDatetime = new SimpleDateTime();
const schedule = new SimpleSchedule('161050499417811121'); // sys_schedule.sys_id
ss.info('Seconds Left: ' + schedule.whenNext(startDatetime).getDurationSeconds()); // Info: Seconds Left: 6052

whenWillExpire(startDateTime, finalWorkingSeconds)


This method determines the time after working seconds value specified in the finalWorkingSeconds parameter passes.

Note

Please note that finalWorkingSeconds parameter does not support negative values.


Parameter(s):

NameTypeMandatoryDefault Value
startDate

SimpleDateTime

YN
finalWorkingSecondsIntegerYN


Return:

TypeDescription
SimpleDateTime object or 'null'This method returns the SimpleDateTime object.


Note

If the SimpleSchedule class object is not valid (the isValid() method returns 'false' for this object), then the whenWillExpire() method returns 'null' for it.


Example:

Code Block
languagejs
titlewhenWillExpire
const startDatetime = new SimpleDateTime('2022-01-23 08:00:00');
const finalWorkingSeconds = 5 * 8 * 3600; // duration of 5 eight-hour days in seconds
const schedule = new SimpleSchedule('161050499417811121'); // sys_schedule.sys_id
ss.info(schedule.whenWillExpire(startDatetime, finalWorkingSeconds).getValue()); // Info: 2022-01-28 18:30:00


Table of Contents
absoluteUrltrue
classfixedPosition

...

Описание: Определяет, сколько времени (в секундах) до времени начала следующего элемента расписания.

Принимает: time - SimpleDateTime; (опционально) timeZone - string (по умолчанию - пустая строка).

Возвращает: integer.

Пример:

let startDate = new SimpleDateTime('2019-10-25 08:00:00');
let simple_schedule = new SimpleSchedule('1', 'Europe/Moscow');
ss.info(simple_schedule.whenNext(startDate));

Parameter(s):

...

Return:

...

Example:

...