Versions Compared

Key

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

This class provides methods for performing operations on SimpleDateTime objects, such as instantiating objects, for exampleThe class is used to conduct operations on SimpleDateTime objects, for example, instantiating objects.

You can also use this class to perform calculate, change formats of the date-time operations, such as calculations, formatting or converting between date-time or convert between the formats.

addDays

SimpleDateTime(

days

dateTime)

This method adds a specified number of days to the current SimpleDateTime object. The negative value of the parameter will subtract the days.

The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the days using local date and time values

Use this constructor to instantiate a new SimpleDateTime object with the current or transferred date/time. Specify the date and time value in the UTC timezone.

Parameter(s):

TypeDescriptionVoidThis method does not return a value.
NameTypeMandatoryDefault Value
daysdateTimeintegerStringYN

Return:

''


Example:

Code Block
languagejs
themeEclipse
titleaddDaysUTCSimpleDateTime
linenumberstrue
const nowDateTime = new SimpleDateTime();
//
const registrationDateTime = new SimpleDateTime(record.registration_datetime);
//
const yearStartDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 0800:00:00");
simple_date_time.addDays(-1)');

You can also use the values in relative format for the SimpleDateTime constructor. All formats are available in the Relative Formats article.

Code Block
languagejs
themeEclipse
titleSimpleDateTime
linenumberstrue
const yesterdayDatetime = new SimpleDateTime('yesterday');
ss.info(simple_date_timeyesterdayDatetime.getValue()); 
// Info: 20182022-1202-3128 0800:00:00

addMonths(months)

This method adds a specified number of months to the current SimpleDateTime object. The negative value of the parameter will subtract the months.

The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the months using local date and time values.

Parameter(s):

NameTypeMandatoryDefault ValuemonthsIntegerYN

Return:

TypeDescriptionVoidThis method does not return a value.

Example:

Code Block
languagejs
titleaddMonthsUTCTime
var simple_date_time  

const tomorrowDatetime = new SimpleDateTime('tomorrow');
ss.info(tomorrowDatetime.getValue());
// Info: 2022-03-02 00:00:00

const yesterdayWorkdayDayStart = new SimpleDateTime('yesterday 06:30');
ss.info(yesterdayWorkdayDayStart.getValue());
// Info: 2022-02-28 06:30:00

const fistDayOfNextMonthStart = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addMonths(-1)'first day of next month 00:00');
ss.info(simple_date_timefistDayOfNextMonthStart.getValue()); 
// 2018-12Info: 2022-04-01 0800:00:00

addSeconds(seconds)

This method adds a specified number of seconds to the current SimpleDateTime object.

Parameter(s):

NameTypeMandatoryDefault ValuesecondsIntegerYN

Return:

TypeDescriptionVoidThis method does not return a value.

Example:

Code Block
languagejs
titleaddSeconds
var simple_date_time

const rangeStartDatetime = new SimpleDateTime(`first day of ${monthName}`);
ss.info(rangeStartDatetime .getValue());
// Info: 2022-02-01 00:00:00

const YEAR = 2022;
const MONTH = 2;
const monthDatetime = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addSeconds(3600`${YEAR}-${String(MONTH).padStart(2, '0')}-02 00:00:00`);
const monthName = monthDatetime.getMonthUTC();
ss.info(simple_date_time.getValue()monthName); 
// 2019-01-01 09:00:00
addWeeks(weeks
Info: February


addDays(days)


This method adds a specified is used to change the number of weeks to days in the current SimpleDateTime object according to the local date and time. The negative positive value of the parameter will subtract the weeks.The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the weeks using local date and time valuesadds days to the object, the negative value diminishes the number of days.


Parameter(s):

NameTypeMandatoryDefault Value
weeksdaysIntegerintegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddWeeksUTCaddDays
linenumberstrue
const registrationDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addWeeks(-1)registrationDateTime.addDays(3);
ss.info(simple_date_timeregistrationDateTime.getValue()); 
//Info: 20182019-1201-2504 08:0012:0010
addYears

addMonths(

years

months)


This method adds a specified is used to change the number of years to months in the current SimpleDateTime object according to the local date and time. The negative positive value of the parameter will subtract the years.The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the years using local date and time valuesadds months to the object, the negative value diminishes the number of months.


Parameter(s):

NameTypeMandatoryDefault Value
yearsmonthsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddMonths
linenumberstrueaddYearsLocalTime
var simple_date_timeconst registrationDateTime = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addYears(registrationDateTime.addMonths(-1);
ss.info(simple_date_timeregistrationDateTime.getValue()); 
//Info: 20202018-0112-01
after(dateTime
 08:12:10

addSeconds(seconds)


This method allows to compare the date specified by the ‘dateTime‘ parameter with the current date. The method returns TRUE, if the current date is after the specified; otherwise returns FALSEis used to change the number of seconds in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds seconds to the object, the negative value diminishes the number of seconds.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimesecondsSimpleDateTime objectIntegerYN


Return:

TypeDescription
Boolean
Void
The method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSE
This method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddSeconds
linenumbersaftertrue
var first_simple_date_timeconst registrationDateTime = new SimpleDateTime("'2019-01-01 08:0012:00"10');
var second_simple_date_time = new SimpleDateTime("2018-01-01 08:00:00");
let result = first_simple_date_time.after(second_simple_date_time);
ss.info(result) // true

before(dateTime)

This method allows to compare the date specified by the ‘dateTime‘ parameter with the current date.

registrationDateTime.addSeconds(3600);
ss.info(registrationDateTime.getValue());
//Info: 2019-01-01 09:12:10

addWeeks(weeks)


This method is used to change the number of weeks in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds weeks to the object, the negative value diminishes the number of weeksThe method returns TRUE, if the current date is before the specified; otherwise returns false.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeweeksSimpleDateTime objectIntegerYN


Return:

TypeDescription
Boolean
Void
The method returns TRUE if the current date is earlier than the date specified by the parameter; otherwise, returns FALSE.
This method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlebeforeaddWeeks
linenumberstrue
const registrationDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:0012:00"10');
var second_simple_date_time = new SimpleDateTime("2018-01-01 08:00:00");
let result = first_simple_date_time.before(second_simple_date_time);
ss.info(result) // false

compareTo(dateTime)

registrationDateTime.addWeeks(1);
ss.info(registrationDateTime.getValue());
//Info: 2019-01-08 08:12:10

addYears(years)


This method is used to change the number of years in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds years to the object, the negative value diminishes the number of yearsThis method compares two date and time objects to determine whether they are equivalent or not.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeyearsSimpleDateTime objectIntegerYN


Return:

TypeDescription
0Dates are equal1Object's date is after the date specified in the parameter.-1Object's date is before the date specified in the parameter.

Example:

VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddYears
linenumberstrue
const contractStartDateTime
Code Block
languagejs
titlecompareTo
var first_simple_date_time = new SimpleDateTime("'2019-01-01 0800:00:00");
var second_simple_date_time = new SimpleDateTime("2018-01-01 08:00:00");
var third_simple_date_time = new SimpleDateTime("2018');
contractStartDateTime.addYears(1);
ss.info(contractStartDateTime.getValue());
//Info: 2020-01-01 0800:00:00");

ss.info( first_simple_date_time.compareTo(second_simple_date_time) ); // 1
ss.info( second_simple_date_time.compareTo(first_simple_date_time) ); // -1
ss.info( third_simple_date_time.compareTo(second_simple_date_time ) ); // 0

equals(dateTime)

This method compares a datetime with an existing value if they are equal.

Parameter(s):

NameTypeMandatoryDefault ValuedateTimeSimpleDateTime object.YN

after(dateTime)


This method allows to compare the date specified by the ‘dateTime‘ parameter with the current date. 

The method returns TRUE, if the current date is after the specified; otherwise returns FALSE.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

TypeDescription
BooleanThe method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titleafter
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartAfterThanEnd = startDateTime.after(endDateTime);
ss.info(isStartAfterThanEnd);
//Info: false

before(dateTime)


This method allows to compare the date specified by the ‘dateTime‘ parameter with the current date.

The method returns TRUE, if the current date is before the specified; otherwise returns false.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

TypeDescription
BooleanThe method returns TRUE if the current date is earlier than the date specified by the parameter; otherwise, returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titlebefore
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartBeforeEnd = startDateTime.before(endDateTime);
ss.info(isStartBeforeEnd);
//Info: true

compareTo(dateTime)


This method compares two date and time objects to determine whether they are equal and, if not, the method defines which goes after or before the other.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

TypeDescription
0Dates are equal.
1Object's date is after the date specified in the parameter.
-1Object's date is before the date specified in the parameter.


Example:

Code Block
languagejs
themeEclipse
titlecompareTo
linenumberstrue
const begin = new SimpleDateTime('2019-04-01 08:15:00');
const end = new SimpleDateTime('2019-05-01 01:00:00');

ss.info(begin.compareTo(end));   // -1
ss.info(end.compareTo(begin));   // 1
ss.info(begin.compareTo(begin)); // 0

equals(dateTime)


This method compares a datetime with an existing value to determine whether they are equal or not.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime object.YN


Return:

TypeDescription
BooleanThis method returns TRUE if the date are equal; otherwise, it returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titleequals
linenumberstrue
const firstDateTime = new SimpleDateTime('2018-01-01 08:00:00');
const secondDateTime = new SimpleDateTime('2018-01-01 08:15:00');
const thirdDateTime = new SimpleDateTime('2018-01-01 08:00:00');

ss.info(firstDateTime.equals(secondDateTime));
ss.info(thirdDateTime.equals(firstDateTime));
//Info: false
//Info: true

getDate()


This method returns the date saved by the SimpleDateTime object in the system time zone.


Return:

TypeDescription
StringThe date in the default timezone.


Example:

Code Block
languagejs
themeEclipse
titlegetDate
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDate());
//Info: 2019-01-01

getDayOfMonthLocalTime()


This method returns the day of the month saved by the SimpleDateTime object in the current user's time zone.


Return:

TypeDescription
IntegerThe day of the month value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfMonthLocalTime());
//Info: 7

getDayOfMonthUTC()


This method returns the day of the month saved by the SimpleDateTime object in the UTC time zone.


Return:

TypeDescription
IntegerThe day of the month value

Return:

TypeDescriptionBooleanThis method returns TRUE if the date are equal; otherwise, it returns FALSE
.


Example:

Code Block
languagejs
titlethemeequalsEclipse
titlegetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
var second_simple_date_time = new SimpleDateTime("2018-01-01 08:00:00");
var third_simple_date_time = new SimpleDateTime("2018'2019-01-0107 08:00:00");

ss.info( first_simple_date_time.equals(second_simple_date_time) ); // 0');
ss.info( third_simple_date_time.equals(second_simple_date_time ) ); // 1
getDate
(holidayDateTime.getDayOfMonthUTC());
//Info: 7

getDayOfWeekLocalTime()


This method returns the date stored by the SimpleDateTime object, showed in the system time zone.

Return:

day of the week saved by the SimpleDateTime object in the current user's time zone.


Return:

TypeDescription
StringThe day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 
TypeDescriptionStringThe date in the default timezone.


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTime
linenumbersgetDatetrue
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-01-0107 08:00:00"');
ss.info( first_simple_date_time.getDateholidayDateTime.getDayOfWeekLocalTime() ); // 2019-01-01
getDaysInMonthLocalTime
Mon

getDayOfWeekUTC()


This method returns the number day of days in the month week saved by the SimpleDateTime object , showed in the user's time zone.

Return:

in the system time zone.


Return:

TypeDescription
StringThe day of week value.
Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 
TypeDescriptionIntegerThe number of days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekUTC
linenumbersgetDaysInMonthLocalTimetrue
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-01-0107 08:00:00"');
ss.info( first_simple_date_time.getDaysInMonthLocalTimeholidayDateTime.getDayOfWeekUTC() ); 
//Info: 31Mon
getDayOfMonthLocalTime

getDaysInMonthLocalTime()


This method returns the day number of days in the month saved by the SimpleDateTime object , showed in the current user's time zone.


Return:

TypeDescription
IntegerThe
day
number of
the month
days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTimegetDaysInMonthLocalTime
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfMonthLocalTimestartDateTime.getDaysInMonthLocalTime() ); 
//Info: 131
getDayOfMonthUTC

getDaysInMonthUTC()


This method returns the day number of days in the month saved by the SimpleDateTime object , showed in the UTC system time zone.


Return:

TypeDescription
IntegerThe
day
number of
the month
days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthUTC
linenumbersgetDaysofMonthsLocalTimetrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfMonthUTCstartDateTime.getDaysInMonthUTC() );
getDayOfWeekLocalTime

//Info: 31

getDisplayValue()


This method returns the day of the week saved by the SimpleDateTime object, showed date and time value in the current user's time zonedisplay format and timezone.


Return:

TypeDescription
StringThe
day of week
date and time value.


Example:

Code Block
languagejs
titlegetDayOfWeekLocalTime
languagejs
themeEclipse
titlegetDisplayValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDisplayValue()); // current user's timezone is Europe/Moscow
//Info: var first_simple_date_time = new SimpleDateTime("2019-01-01 0811:00:00");
ss.info( first_simple_date_time.getDayOfWeekLocalTime() ); // Tue
getDayOfWeekUTC

getErrorMsg()


This method returns the day of the week saved by the SimpleDateTime object, showed in the system time zoneerror message if the SimpleDateTime object was incorrect.


Return:

TypeDescription
StringThe
day of week value
error message.


Example:

Code Block
languagejs
titlegetDayOfWeekUTC
js
themeEclipse
titlegetErrorMsg
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01zz-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfWeekUTC() );
getDaysInMonthUTC
error(startDateTime.getErrorMsg());
//Error: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given

getLocalDate()


This method returns the number of days in the month returns the date saved by the SimpleDateTime object , showed in the system current user's time zone.


Return:

TypeDescription
Integer
StringThe
number of days value
date in the user's time zone.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthUTCgetLocalDate
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDaysInMonthUTC() );
getDisplayValue
startDateTime.getLocalDate());
//Info: 2019-01-01

getLocalTime()


This method gets returns the date and time value time saved in a SimpleDateTime object in the current user's display format and timezonetime zone .


Return:

TypeDescription
String
SimpleDateTimeThe
date and time value
time in the user's time zone.


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValuegetLocalTime
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"01 08:00:00');
const time = startDateTime.getLocalTime();
ss.info( first_simple_date_time.getDisplayValue() ) ; //uses current user session time zone
getErrorMsg
 "My local time is " + time.getByFormat('h:i:s'));
//Info: My local time is 02:00:00

getMonthLocalTime()


This method gets the error message if the SimpleDateTime object was incorrectreturns the month saved by SimpleDateTime object in the current user's time zone.


Return:

TypeDescription
StringThe
error message
value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetErrorMsggetMonthLocalTime
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-zz12-0131 0823:0045:00"');
ss.info( first_simple_date_time.getErrorMsgstartDateTime.getMonthLocalTime() ) ;  //The parsed date or time was invalid!
getLocalDate

//Info: January

getMonthUTC()


This method returns the date stored month saved by the SimpleDateTime object , showed in the user's system time zone.


Return:

TypeDescription
StringThe
date in the user's time zone
value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetLocalDategetMonthUTC
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getLocalDate() )
getLocalTime
info(startDateTime.getMonthUTC());
//Info: December

getNumericValue()


This method returns a SimpleDateTime object that shows the time in the user's time zonethe Unix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00.


Return:

TypeDescription
SimpleDateTime
IntegerThe
time in the user's time zone
Unix timestamp value.


Example:

Code Block
languagejs
themeEclipse
titlegetLocalTimegetNumericValue
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00");
var time = first_simple_date_time.getLocalTime(');
ss.info( "My local time is " + time.getByFormat('h:m:s') ) ;
getMonthLocalTime
startDateTime.getNumericValue());
//Info: 1546329600

getTime()


This method returns the month saved by a SimpleDateTime object , showed in the current user's time zonethat shows the piece of time of the SimpleDateTime object.


Return:

TypeDescription
String
SimpleDateTimeThe
value of the month
Unix duration stamp.


Example:

Code Block
languagejs
themeEclipse
titlegetTime
linenumbersgetMonthLocalTimetrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
const time = startDateTime.getTime();
ss.info( first_simple_date_time.getMonthLocalTime() getByFormat('h:i:s')); 
// January
getMonthUTC
Info: 11:01:00

getValue()


This method returns the month saved by SimpleDateTime object, showed in the system time zonedate and time value in the internal format.


Return:

TypeDescription
String
null | stringThe date and time value
of
in the
month
internal format.


Example:

Code Block
languagejs
themeEclipse
titlegetValue
linenumberstruegetMonthUTC
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getMonthUTCstartDateTime.getValue() );
getNumericValue
 // 2019-01-01 08:00:00

getWeekOfYearLocalTime()


This method gets the timestamp which stores the amount of milliseconds since January 1, 1970, 00:00:00returns the week's number saved by the SimpleDateTime object in the current user's time zone.


Return:

TypeDescription
IntegerThe
timestamp value
number of the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetNumericValuegetWeekOfYearLocalTime
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getNumericValuestartDateTime.getWeekOfYearLocalTime() ) ; 
//Info: 15463188001
getTime

getWeekOfYearUTC()


This method returns a the number of the week saved by the SimpleDateTime object that shows in the piece of time of the SimpleDateTime objectsystem time zone.


Return:

TypeDescription
SimpleDateTime
IntegerThe
Unix duration stamp
number of the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearUTC
linenumbersgetTimetrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00");
var time = first_simple_date_time.getTime(');
ss.info( time.getByFormat('h:m:s') );
getValue
startDateTime.getWeekOfYearUTC());
//Info: 1

getYearLocalTime()


This method gets the date and time value in the internal formatreturns the year saved by the SimpleDateTime object in the current user's time zone.


Return:

TypeDescription
null | stringThe date and time value in the internal format
IntegerFour-digit year value.


Example:

Code Block
languagejs
themeEclipse
titlegetValuegetYearLocalTime
linenumberstrue
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getValueholidayDateTime.getYearLocalTime() ); 
//2019-01-01 08:00:00
getWeekOfYearLocalTime
Info: 2020

getYearUTC()


This method returns the number of the week year saved by the SimpleDateTime object , showed in the user's system time - zone.


Return:

TypeDescription
Integer
The number of the current week
Four-digit year value.


Example:

Code Block
languagejs
titlegetWeekOfYearLocalTime
languagejs
themeEclipse
titlegetYearUTC
linenumberstrue
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getWeekOfYearLocalTimeholidayDateTime.getYearUTC() ); 
//Info: 12019
getWeekOfYearUTC

isValid()


This method returns the number of the week saved by the SimpleDateTime object, showed in the system time-zoneallows to determine if a specified value is a valid date and time.


Return:

TypeDescription
Integer
BooleanThe
number of the current week
method returns TRUE if the value is a valid date and time; otherwise, it returns .


Example:

Code Block
languagejs
themeEclipse
titleisValid
linenumbersgetWeekOfYearUTCtrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("2019-01'2019-01-01 08:00:00');
startDateTime.setValue('2011-aa-01 0800:00:00"');
ss.info( first_simple_date_time.getWeekOfYearUTCstartDateTime.isValid() );
getYearLocalTime(

//Info: false

setValue(dateTime)


This method

returns the year saved by

is intended to define the date and time value within the SimpleDateTime object

, showed in the user's time zone

.

Return:

TypeDescriptionIntegerFour-digit year value.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeA string in the UTC timezone and the internal format of YYYY-MM-DD hh:mm:ss.YN
dateTimeA SimpleDateTime object.YN
dateTimeA JavaScript Number. It sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00.YN


Example:

Code Block
languagejs
titlegetYearLocalTime
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
ss.info( first_simple_date_time.getYearLocalTime()

getYearUTC()

This method returns the year saved by the SimpleDateTime object, showed in the system time zone.

Return:

TypeDescription
IntegerFour-digit year
VoidThis method does not return a value.


Example:

Code Block
languagejs
titlegetYearUTC
js
themeEclipse
titlesetValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
startDateTime.setValue('2020-01-01 12:00:00');
ss.info(startDateTime.getValue());
//Info: 2020var first_simple_date_time = new SimpleDateTime("2019-01-01 0812:00:00");
ss.info( first_simple_date_time.getYearUTC() );

isValid()

This method allows to determine if a specified value is a valid date and time. 

Return:

subtract(first, second)


This method returns the amount of time between two SimpleDateTime values. Also, it can subtract the amount of time from the current SimpleDateTime object.

Note

Displaying of the final value using the getDisplayValue() method returns it considering the current user' timezone, unlike the getValue() method. It returns data only in UTC timezone.


Parameter(s):

NameTypeMandatoryDefault Value
first

SimpleDateTime Object

YN
secondSimpleDateTime ObjectNNULL


Return:

Type
SimpleDuration object
TypeDescriptionBooleanThe method returns TRUE if the value is a valid date and time; otherwise, it returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titlesubtract #1
linenumbersisValidtrue
var first_simple_date_timeconst startDatetime = new SimpleDateTime("'2019-0111-01 08:00:00");
first_simple_date_time.setDisplayValue("2011-aa-01 00 20:00:00"');
ss.info( first_simple_date_time.isValid() ) ;  // false

setValue(dateTime)

This method sets the date and time of the SimpleDateTime object.

Parameter(s):

NameTypeMandatoryDefault ValuedateTimeA string in the local time zone and the internal format of yyyy-MM-dd HH:mm:ss.YNdateTimeA SimpleDateTime object,YNdateTimeA JavaScript Number. It sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00.YN
const endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const diffDuration = new SimpleDateTime().subtract(startDatetime, endDatetime); 
ss.info(diffDuration.getDurationSeconds());
// Info: 388

Same example without using of the subtract

Return:

TypeDescriptionVoidThis method does not return a value.Example

:

Code Block
languagejs
titlesetValue
themeEclipse
linenumberstrue
const startDatetimevar first_simple_date_time = new SimpleDateTime("'2019-0111-0108 0820:00:00"');
first_simple_date_time.setValue("2020-01-01 12:00:00");const endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const diffSeconds = endDatetime.getNumericValue() - startDatetime.getNumericValue(); 
ss.info( first_simple_date_time.getValue() diffSeconds);  
// 2020-01-01 12:00:00

subtract(first, second)

This method gets the duration between to SimpleDateTime values. Also, it can subtract the amount of time from the current SimpleDateTime object.

Parameter(s):

NameTypeMandatoryDefault Valuefirst

SimpleDateTime Object

YNfirst

SimpleTime Object

YNfirst

Number (milliseconds)

YNsecondSimpleDateTime ObjectNNULLsecondSimpleTime ObjectNNULLsecondNumber (milliseconds)NNULL
Info: 388


Code Block
languagejs
themeEclipse
titlesubtract #2
linenumberstrue
const datetime = new SimpleDateTime('2020-08-28 09:00:00');
datetime.subtract(3600);
ss.info(datetime.getValue());
//Info: 2020-08-28 08:00:00

Same example without using of the subtract

Return:

TypeSimpleDuration objectExample

:

Code Block
languagejs
themeEclipse
titlesubtract #2
linenumberstrue
const datetimevar simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");

var simple_time = new SimpleTime();
simple_time.setValue("00:00:20");

simple_date_time.subtract(simple_time);

var second_simple_time  = simple_date_time.getTime('2020-08-28 09:00:00');
datetime.addSeconds(-3600);
ss.info( second_simple_time.getByFormat('h:m:s') ); // 2019-01-01 07:59:40datetime.getValue());
//Info: 2020-08-28 08:00:00


Table of Contents
absoluteUrltrueclassfixedPosition