You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 48 Next »

This class provides methods for performing operations on SimpleDateTime objects, such as instantiating objects, for example.

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

addDaysLocalTime(days)

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 GlideDateTime object, then adds or subtracts the days using local date and time values.


Parameter(s):

NameType
daysInteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addDaysLocalTime
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addDaysLocalTime(-1)
ss.info(simple_date_time.getValue()); // 2018-12-31

addDaysUTC(days)

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

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


Parameter(s):

NameType
daysinteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addDaysUTC
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addDaysUTC(-1)
ss.info(simple_date_time.getValue()); // 2018-12-31 08:00:00

addMonthsLocalTime(months)

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 GlideDateTime object, then adds or subtracts the months using local date and time values.


Parameter(s):

NameType
monthsInteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addMonthsLocalTime
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addMonthsLocalTime(1)
ss.info(simple_date_time.getValue()); // 2019-02-01

addMonthsUTC(months)

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

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


Parameter(s):

NameType
monthsInteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addMonthsUTCTime
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addMonthsUTC(-1)
ss.info(simple_date_time.getValue()); // 2018-12-01 08:00:00

addSeconds(seconds)

Add a specified number of seconds to the current SimpleDateTime object.


Parameter(s):

NameType
secondsInteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addSeconds
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addSeconds(3600);
ss.info(simple_date_time.getValue()); // 2019-01-01 09:00:00

addWeeksLocalTime(weeks)

Adds a specified number of weeks to the current SimpleDateTime object. The negative value of the parameter will subtract the weeks.

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


Parameter(s):

NameType
weeksinteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addWeeksLocalTime
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addWeeksLocalTime(2)
ss.info(simple_date_time.getValue()); // 2019-01-15

addWeeksUTC(weeks)

Adds a specified number of weeks to the current SimpleDateTime object. The negative value of the parameter will subtract the weeks.

The method determines UTC date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the weeks using UTC date and time values.


Parameter(s):

NameType
weeksInteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addWeeksUTC
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addWeeksUTC(-1)
ss.info(simple_date_time.getValue()); // 2018-12-25 08:00:00

addYearsLocalTime(years)

Adds a specified number of years to the current SimpleDateTime object. The negative value of the parameter will subtract the years.

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


Parameter(s):

NameType
YearsInteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addYearsLocalTime
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addYearsLocalTime(1)
ss.info(simple_date_time.getValue()); // 2020-01-01

addYearsUTC(years)

Adds a specified number of years to the current SimpleDateTime object. The negative value of the parameter will subtract the years.

The method determines UTC date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the years using UTC date and time values.


Parameter(s):

NameType
YearsInteger


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addYearsLocalTime
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addYearsLocalTime(1)
ss.info(simple_date_time.getValue()); // 2020-01-01

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):

NameType
dateTimeSimpleDateTime object


Return:

TypeDescription
BooleanReturns true if the current date is later than the date specified by the parameter.


Example:

after
var 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");
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.

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


Parameter(s):

NameType
dateTimeSimpleDateTime object


Return:

TypeDescription
BooleanReturns true if the current date is earlier than the date specified by the parameter.


Example:

before
var 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");
let result = first_simple_date_time.before(second_simple_date_time);
ss.info(result) // false

compareTo(dateTime)

Compares two date and time objects to determine whether they are equivalent or not.


Parameter(s):

NameType
dateTimeSimpleDateTime object


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:

compareTo
var 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-01-01 08: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)

Compares a datetime with an existing value if they are equal.


Parameter(s):

NameType
dateTimeSimpleDateTime object.


Return:

TypeDescription
BooleanReturns true if the date are equal; otherwise returns false.


Example:

equals
var 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-01-01 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

getDaysInMonthLocalTime()

Returns the number of days in the month saved by the SimpleDateTime object, showed in the user's time zone.


Return:

TypeDescription
IntegerThe number of days value.


Example:

getDaysInMonthLocalTime
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
ss.info( first_simple_date_time.getDaysInMonthLocalTime() ); // 31

getDaysInMonthUTC()

Returns the number of days in the month saved by the SimpleDateTime object, showed in the system time zone.


Return:

TypeDescription
IntegerThe number of days value.


Example:

getDaysInMonthUTC
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
ss.info( first_simple_date_time.getDaysInMonthUTC() );

  • No labels