namespace sap/ui/core/date/UniversalDateUtils

Visiblity: restricted
Available since: N/A
Module: sap/ui/core/date/UniversalDateUtils
Application Component:

Provides helpers to execute common calculations on UniversalDate instances.


Nodes Overview

Node Description

Methods Overview

Method Description
module:sap/ui/core/date/UniversalDateUtils.getMonthStartDate

Returns the first day of the month of the given date.

If no date is given, today is used, represented in the session's default calendar. If a date is given, the returned date will use the same calendar. The time portion of the returned date will be set to the beginning of the day (0:00:00:000).

module:sap/ui/core/date/UniversalDateUtils.getQuarterStartDate

Returns the first day of the quarter of the year of the given date.

If no date is given, today is used, represented in the session's default calendar. If a date is given, the returned date will use the same calendar. The time portion of the returned date will be set to the beginning of the day (0:00:00:000).

module:sap/ui/core/date/UniversalDateUtils.getRange

Calculates a date range based on a given base date, duration and unit.

If no or a null base date is given, today (UniversalDateUtils.createNewUniversalDate()) will be used as base date, represented in the current session's default calendar type.

If the duration is 0, the base date will be used and is part of the returned range. 0 WEEK means this week. If the duration is positive, the base date will be used as start date of the range. 1 WEEK means next week. If the duration is negative, the base date will be used as end date. This method expects only integer values for iDuration, any fractional part will be ignored (truncated).

The unit can be one of "DAY", "WEEK", "MONTH", "QUARTER" or "YEAR".

The first value in the returned array will be the first day within the calculated range (start date) with the time portion set to the beginning of the day. The second value in the array will be the last day within the range (the inclusive end date) with the time portion set to the end of the day.

The returned dates will use the same calendar as the given base date. If no base date was given, they will use the session's default calendar type.

module:sap/ui/core/date/UniversalDateUtils.getWeekStartDate

Returns the first day of the week of the given date.

The interpretation of 'first day of the week' depends on the given locale or, if none is given, on the current UI5 format locale.

If no date is given, today is used, represented in the session's default calendar. If a date is given, the returned date will use the same calendar. The time portion of the returned date will be set to the beginning of the day (0:00:00:000).

module:sap/ui/core/date/UniversalDateUtils.getYearStartDate

Returns the year's start date based on a given universal date.

If no date is given, today is used, represented in the session's default calendar. If a date is given, the returned date will use the same calendar. The time portion of the returned date will be set to the beginning of the day (0:00:00:000).

module:sap/ui/core/date/UniversalDateUtils.resetEndTime

Returns a copy of the given date with the time portion set to 23:59:59:999

If no date is given, today will be used, represented in the session's default calendar.

module:sap/ui/core/date/UniversalDateUtils.resetStartTime

Returns a copy of the given date with the time portion set to 00:00:00.000.

If no date is given, today will be used, represented in the session's default calendar.

module:sap/ui/core/date/UniversalDateUtils.getMonthStartDate

Returns the first day of the month of the given date.

If no date is given, today is used, represented in the session's default calendar. If a date is given, the returned date will use the same calendar. The time portion of the returned date will be set to the beginning of the day (0:00:00:000).

Param Type DefaultValue Description
oUniversalDate sap.ui.core.date.UniversalDate now

Base date, defaults to now

module:sap/ui/core/date/UniversalDateUtils.getQuarterStartDate

Returns the first day of the quarter of the year of the given date.

If no date is given, today is used, represented in the session's default calendar. If a date is given, the returned date will use the same calendar. The time portion of the returned date will be set to the beginning of the day (0:00:00:000).

Param Type DefaultValue Description
oUniversalDate sap.ui.core.date.UniversalDate now

Base date, defaults to now

module:sap/ui/core/date/UniversalDateUtils.getRange

Calculates a date range based on a given base date, duration and unit.

If no or a null base date is given, today (UniversalDateUtils.createNewUniversalDate()) will be used as base date, represented in the current session's default calendar type.

If the duration is 0, the base date will be used and is part of the returned range. 0 WEEK means this week. If the duration is positive, the base date will be used as start date of the range. 1 WEEK means next week. If the duration is negative, the base date will be used as end date. This method expects only integer values for iDuration, any fractional part will be ignored (truncated).

The unit can be one of "DAY", "WEEK", "MONTH", "QUARTER" or "YEAR".

The first value in the returned array will be the first day within the calculated range (start date) with the time portion set to the beginning of the day. The second value in the array will be the last day within the range (the inclusive end date) with the time portion set to the end of the day.

The returned dates will use the same calendar as the given base date. If no base date was given, they will use the session's default calendar type.

Param Type DefaultValue Description
iDuration int

Positive or negative integer value that defines the duration of the date range.

sUnit string

Unit of iDuration, one of "DAY", "WEEK", "MONTH", "QUARTER" , "YEAR".

oBaseDate sap.ui.core.date.UniversalDate now

Universal date used as basis for the range calculation, defaults to now

bBaseOnUnit boolean

Resets the oBaseDate to the first day of the corresponding sUnit where oBaseDate is included. E.g. for the unit "MONTH", it will reset to the first day of that month. This option is applicable to the units "WEEK","MONTH","QUARTER","YEAR", for unit "DAY" it has no effect. For unit "WEEK", the first day depends on the locale settings (see method #.getWeekStartDate)

module:sap/ui/core/date/UniversalDateUtils.getWeekStartDate

Returns the first day of the week of the given date.

The interpretation of 'first day of the week' depends on the given locale or, if none is given, on the current UI5 format locale.

If no date is given, today is used, represented in the session's default calendar. If a date is given, the returned date will use the same calendar. The time portion of the returned date will be set to the beginning of the day (0:00:00:000).

Param Type DefaultValue Description
oUniversalDate sap.ui.core.date.UniversalDate now

Base date, defaults to now

sLocale string format locale

An optional locale identifier, as BCP language tag; defaults to the current format local of UI5

module:sap/ui/core/date/UniversalDateUtils.getYearStartDate

Returns the year's start date based on a given universal date.

If no date is given, today is used, represented in the session's default calendar. If a date is given, the returned date will use the same calendar. The time portion of the returned date will be set to the beginning of the day (0:00:00:000).

Param Type DefaultValue Description
oUniversalDate sap.ui.core.date.UniversalDate now

Base date, defaults to now

module:sap/ui/core/date/UniversalDateUtils.resetEndTime

Returns a copy of the given date with the time portion set to 23:59:59:999

If no date is given, today will be used, represented in the session's default calendar.

Param Type DefaultValue Description
oUniversalDate sap.ui.core.date.UniversalDate now

Date, defaults to now

module:sap/ui/core/date/UniversalDateUtils.resetStartTime

Returns a copy of the given date with the time portion set to 00:00:00.000.

If no date is given, today will be used, represented in the session's default calendar.

Param Type DefaultValue Description
oUniversalDate sap.ui.core.date.UniversalDate now

Date, defaults to now