-
Notifications
You must be signed in to change notification settings - Fork 0
Time
The zif_time
interface is a public interface designed to work with time data in the ABAP language. The interface provides several methods for handling time values, validating them, formatting them, comparing them, and performing arithmetic operations on them.
The interface declares one internal type:
-
t_value
of typexsdtime_t
: The type for representing time values.
Here are the methods provided by the zif_time
interface:
-
value
: Returns the value of this time as is. The returned value is of typezif_time=>t_value
. -
valid_value_or_error
: Returns the value of this time if it's valid. If the time is not valid, an error is thrown. The returned value is of typezif_time=>t_value
. -
valid_value_or_fallback
: Returns the value of this time if it's valid. If the time is not valid, a fallback value is returned (which may in turn be also invalid). This method takes in a fallback value of typezif_time=>t_value
and returns a value of typezif_time=>t_value
. -
check
: Throws an error if this time is not valid. The returned value is a reference tozif_time
. -
is_valid
: Returns true if this time is valid. The returned value is of typexsdboolean
. -
to_format
: Returns this time in the specified format. This method takes in a format of typeref to zif_time_format
and returns a formatted time as a string. -
to_format_default
: Returns this time in the default format. The returned value is a formatted time as a string. -
to_format_iso_8601
: Returns this time in the ISO 8601 format. The returned value is a formatted time as a string. -
to_format_of_user
: Returns this time in the format of the specified user. This method takes in a username of typeuname
and returns a formatted time as a string. -
to_format_of_current_user
: Returns this time in the format of the current user. The returned value is a formatted time as a string. -
to_format_of_country
: Returns this time in the format of the specified country. This method takes in a country code of typeland1
and returns a formatted time as a string. -
to_format_24h
: Returns this time in the 24-hour form hh:mm:ss. The returned value is a formatted time as a string. -
to_format_1_to_12_upper
: Returns this time in the 12-hour format hh:mm:ss AM/PM (1 to 12). The returned value is a formatted time as a string. -
to_format_1_to_12_lower
: Returns this time in the 12-hour format hh:mm:ss am/pm (1 to 12). The returned value is a formatted time as a string. -
to_format_0_to_11_upper
: Returns this time in the 12-hour format hh:mm:ss AM/PM (0 to 11). The returned value is a formatted time as a string. -
to_format_0_to_11_lower
: Returns this time in the 12-hour format hh:mm:ss am/pm (0 to 11). The returned value is a formatted time as a string. -
equals
: Returns true if both times have the same valid value. This method takes in another time of typeref to zif_time
and returns a boolean value. -
is_earlier_than
: Returns true
if the supplied time is ahead. This method takes in another time of type ref to zif_time
and returns a boolean value.
-
is_later_than
: Returns true if the supplied time is behind. This method takes in another time of typeref to zif_time
and returns a boolean value. -
is_earlier_than_or_equal_to
: Returns true if the supplied time is ahead or equal. This method takes in another time of typeref to zif_time
and returns a boolean value. -
is_later_than_or_equal_to
: Returns true if the supplied time is behind or equal. This method takes in another time of typeref to zif_time
and returns a boolean value. -
add
: Adds values of provided arguments to this time. This method takes in seconds, minutes, and hours (all of typei
) and returns a new time as a reference tozif_time
. -
subtract
: Subtracts values of provided arguments from this time. This method takes in seconds, minutes, and hours (all of typei
) and returns a new time as a reference tozif_time
. -
hour
: Returns the hour (0-23). The returned value is of typei
. -
seconds_since_midnight
: Returns the seconds since 00:00 (0-86400). The returned value is of typei
. -
second_of_minute
: Returns second of the minute (0-59). The returned value is of typei
. -
minutes_since_midnight
: Returns the minutes since 00:00 (0-1440). The returned value is of typei
. -
minute_of_hour
: Returns minute of the hour (0-59). The returned value is of typei
.
The interface raises two exceptions: zcx_time
and zcx_time_format
. These exceptions are raised when there are problems with the time value or the time format, respectively.
The zcx_time
exception is raised when the time value is not valid or when there is a problem while performing arithmetic operations on the time.
The zcx_time_format
exception is raised when there is a problem with the time format, such as when the format is not recognized or when the time cannot be formatted in the requested format【5†source】.