You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 57 Next »
his 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):
Name | Type |
---|---|
days | Integer |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
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):
Name | Type |
---|---|
days | integer |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
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):
Name | Type |
---|---|
months | Integer |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
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):
Name | Type |
---|---|
months | Integer |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
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):
Name | Type |
---|---|
seconds | Integer |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
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):
Name | Type |
---|---|
weeks | integer |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
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):
Name | Type |
---|---|
weeks | Integer |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
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):
Name | Type |
---|---|
Years | Integer |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
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):
Name | Type |
---|---|
Years | Integer |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
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):
Name | Type |
---|---|
dateTime | SimpleDateTime object |
Return:
Type | Description |
---|---|
Boolean | Returns true if the current date is later than the date specified by the parameter. |
Example:
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):
Name | Type |
---|---|
dateTime | SimpleDateTime object |
Return:
Type | Description |
---|---|
Boolean | Returns true if the current date is earlier than the date specified by the parameter. |
Example:
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):
Name | Type |
---|---|
dateTime | SimpleDateTime object |
Return:
Type | Description |
---|---|
0 | Dates are equal |
1 | Object's date is after the date specified in the parameter. |
-1 | Object's date is before the date specified in the parameter. |
Example:
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):
Name | Type |
---|---|
dateTime | SimpleDateTime object. |
Return:
Type | Description |
---|---|
Boolean | Returns true if the date are equal; otherwise returns false. |
Example:
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
getDate()
Returns the date stored by the GlideDateTime object, showed in the system time zone.
Return:
Type | Description |
---|---|
String | The date in the default timezone. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getDate() ); // 2019-01-01
getDaysInMonthLocalTime()
Returns the number of days in the month saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Type | Description |
---|---|
Integer | The number of days value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getDaysInMonthLocalTime() ); // 31
getDayOfMonthLocalTime()
Returns the day of the month saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Type | Description |
---|---|
Integer | The day of the month value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getDayOfMonthLocalTime() ); // 1
getDayOfMonthUTC()
Returns the day of the month saved by the SimpleDateTime object, showed in the UTC time zone.
Return:
Type | Description |
---|---|
Integer | The day of the month value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getDayOfMonthUTC() );
getDayOfWeekLocalTime()
Returns the day of the week saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Type | Description |
---|---|
String | The day of week value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getDayOfWeekLocalTime() ); // Tue
getDayOfWeekUTC()
Returns the day of the week saved by the SimpleDateTime object, showed in the system time zone.
Return:
Type | Description |
---|---|
String | The day of week value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getDayOfWeekUTC() );
getDaysInMonthUTC()
Returns the number of days in the month saved by the SimpleDateTime object, showed in the system time zone.
Return:
Type | Description |
---|---|
Integer | The number of days value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getDaysInMonthUTC() );
getDisplayValue()
Gets the date and time value in the current user's display format and timezone.
Return:
Type | Description |
---|---|
Null | String |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getDisplayValue() ) ; //uses current user session time zone
getErrorMsg()
Gets the error message if the SimpleDateTime object was incorrect.
Return:
Type | Description |
---|---|
String | The error message. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-zz-01 08:00:00"); ss.info( first_simple_date_time.getErrorMsg() ) ; //The parsed date or time was invalid!
getLocalDate()
Returns the date stored by the GlideDateTime object, showed in the user's time zone.
Return:
Type | Description |
---|---|
String | The date in the user's time zone. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getLocalDate() )
getLocalTime()
Returns a SimpleDateTime object that shows the time in the user's time zone.
Return:
Type | Description |
---|---|
SimpleDateTime | The time in the user's time zone. |
Example:
var 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()
Returns the month saved by SimpleDateTime object, showed in the current user's time zone.
Return:
Type | Description |
---|---|
String | The value of the month. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getMonthLocalTime() ); // January
getMonthUTC()
Returns the month saved by SimpleDateTime object, showed in the system time zone.
Return:
Type | Description |
---|---|
String | The value of the month. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getMonthUTC() );
getNumericValue()
Gets the timestamp which stores the amount of milliseconds since January 1, 1970, 00:00:00.
Return:
Type | Description |
---|---|
Integer | The timestamp |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getNumericValue() ) ; // 1546318800
getTime()
Returns a SimpleDateTime object that shows the piece of time of the SimpleDateTime object.
Return:
Type | Description |
---|---|
SimpleDateTime | The Unix duration stamp. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); var time = first_simple_date_time.getTime(); ss.info( time.getByFormat('h:m:s') );
getValue()
Gets the date and time value in the internal format.
Return:
Type | Description |
---|---|
null | string | The date and time value in the internal format |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getValue() ); //2019-01-01 08:00:00
getWeekOfYearLocalTime()
Returns the number of the week saved by the SimpleDateTime object, showed in the user's time-zone.
Return:
Type | Description |
---|---|
Integer | The number of the current week. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getWeekOfYearLocalTime() ); // 1
getWeekOfYearUTC()
Returns the number of the week saved by the SimpleDateTime object, showed in the system time-zone.
Return:
Type | Description |
---|---|
Integer | The number of the current week. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getWeekOfYearUTC() );
getYearLocalTime()
Returns the year saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Type | Description |
---|---|
Integer | Four-digit year value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); ss.info( first_simple_date_time.getYearLocalTime()
getYearLocalUTC()
Returns the year saved by the SimpleDateTime object, showed in the system zone.
Return:
Type | Description |
---|---|
Integer | Four-digit year value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08: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:
Type | Description |
---|---|
Boolean | Returns true if value is a valid date and time; otherwise, returns false. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); first_simple_date_time.setDisplayValue("2011-aa-01 00:00:00"); ss.info( first_simple_date_time.isValid() ) ; // false
setDisplayValue(dateTime, format)
Sets the dateTime value using the current user's display format and time zone.
Parameter(s):
Name | Type |
---|---|
dateTime | String |
format | String |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); first_simple_date_time.setDisplayValue("2020-01-01 12:00:00"); ss.info( first_simple_date_time.getValue() );
setValue(dateTime)
Sets the date and time of the SimpleDateTime object
Parameter(s):
Name | Type |
---|---|
dateTime | A string in the UTC time zone and the internal format of yyyy-MM-dd HH:mm:ss. |
dateTime | A SimpleDateTime object |
dateTime | A JavaScript Number. Sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00. |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00"); first_simple_date_time.setValue("2020-01-01 12:00:00"); ss.info( first_simple_date_time.getValue() ); // 2020-01-01 12:00:00
subtract(first, second)
This method gets the duration between to SimpleDateTime values. Also it can subtract an amount of time from the current SimpleDateTime object.
Parameter(s):
Name | Type |
---|---|
first | SimpleDateTime Object |
first | SimpleTime Object |
first | Number (milliseconds) |
second | SimpleDateTime Object |
second | SimpleTime Object |
second | Number (milliseconds) |
Return:
Type |
---|
SimpleDuration object |
Example:
var 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(); ss.info( second_simple_time.getByFormat('h:m:s') ); // 2019-01-01 07:59:40
- No labels