Skip to content

Time factory

Francisco Alcaraz edited this page May 23, 2023 · 1 revision

Overview

The ZIF_TIME_FACTORY is a public ABAP interface designed to create instances of the ZIF_TIME interface.

Methods

The interface contains several methods to create and manipulate instances of ZIF_TIME. Each method is explained below:

Null

This method returns a null value for ZIF_TIME.

Parameters:

  • r_time: Returns the null value of ZIF_TIME. Exceptions:
  • zcx_time: Raised if there's an error during the execution.

Initial

This method returns the initial value for ZIF_TIME.

Parameters:

  • r_time: Returns the initial value of ZIF_TIME. Exceptions:
  • zcx_time: Raised if there's an error during the execution.

Min

This method returns the minimum allowed value for ZIF_TIME.

Parameters:

  • r_time: Returns the minimum allowed value of ZIF_TIME. Exceptions:
  • zcx_time: Raised if there's an error during the execution.

Max

This method returns the maximum allowed value for ZIF_TIME.

Parameters:

  • r_time: Returns the maximum allowed value of ZIF_TIME. Exceptions:
  • zcx_time: Raised if there's an error during the execution.

From Timestamp

This method creates a new instance of ZIF_TIME from a given timestamp and a time zone.

Parameters:

  • i_timestamp: Input timestamp.
  • i_to_time_zone: Input time zone.
  • r_time: Returns the newly created instance of ZIF_TIME. Exceptions:
  • zcx_timestamp: Raised if there's an error with the input timestamp.
  • zcx_time_zone: Raised if there's an error with the input time zone.

This pattern continues for other methods: from_timestamp_to_utc_tz, from_timestamp_to_default_tz, from_timestamp_to_system_tz, from_timestamp_to_user_tz, from_timestamp_to_curr_user_tz, from_timestamp_to_country_tz, from_timestamp_to_ctry_regn_tz, from_timestamp_to_ctry_zip_tz, from_timestamp_v2, from_tstamp_v2_to_utc_tz, from_tstamp_v2_to_default_tz, from_tstamp_v2_to_system_tz, from_tstamp_v2_to_user_tz, from_tstamp_v2_to_curr_user_tz, from_tstamp_v2_to_country_tz, from_tstamp_v2_to_ctry_regn_tz, and from_tstamp_v2_to_ctry_zip_tz.

These methods generally follow the same pattern, taking in a timestamp and (usually) a time zone or a related parameter (like a country, region, or user),

and returning an instance of ZIF_TIME. Each of these methods has their own specific purpose and is used to create ZIF_TIME in different contexts.

From Timestamp to UTC Time Zone

This method creates a new instance of ZIF_TIME from a given timestamp converted to UTC time zone.

Parameters:

  • i_timestamp: Input timestamp.
  • r_time: Returns the newly created instance of ZIF_TIME converted to UTC time zone. Exceptions:
  • zcx_timestamp: Raised if there's an error with the input timestamp.
  • zcx_time_zone: Raised if there's an error with the time zone conversion.

The other methods follow the same structure with their specific contexts, such as from_timestamp_to_default_tz for the default time zone, from_timestamp_to_system_tz for the system time zone, from_timestamp_to_user_tz for a specific user's time zone, and so on.

The second set of methods starting with from_tstamp_v2... follow a similar structure as well, but are designed to work with version 2 timestamps (zif_timestamp_v2).

Raising Exceptions

There are two types of exceptions that may be raised during the execution of these methods:

  • zcx_timestamp: Raised if there's an error with the input timestamp.
  • zcx_time_zone: Raised if there's an error with the input time zone or during the conversion process【5†source】.
Clone this wiki locally