Time Types

Overview

The primitive Date/Time types used in openEHR are represented by classes defined in the package base.foundation_types.time. These are concrete types based on the ISO 8601 (2019) date/time standard semantics, which supports partial dates, times, and complex durations, all of which are needed in the biomedical and clinical domains. These classes have a String physical representation. and are assumed to exist in close to the form specified here, because they are specified in other openEHR specifications.

The time package is shown below.

BASE foundation types.time
Figure 1. base.foundation_types.time package

Primitive Time Types

The set of ISO 8601 based types define dates and times with a String representation (as per ISO 8601), and the ISO 8601 'partial' and 'extended' semantics. They are defined as descendents of the native types described above, and add the necessary elements required for ISO 8601.

class names of the form Iso8601_xxx have been used here to clearly identify these classes where used elsewhere in the openEHR specifications. In real implementations, other class names may be used as convenient, just as for the other primitive types.
For reasons of readability in data, it is strongly recommended that the 'extended' form of date and time strings be used when writing and displaying data, rather than the compact form. An extended date has the form yyyy-mm-dd rather than yyyymmdd, and an extended time has the form hh:mm:ss rather than hhmmss. Nevertheless, both forms should be supported so that openEHR-based systems that use 'straight-through' processing on legacy data that may be in the compact form remain conformant to the specifications.

ISO 8601 semantics not included in these types include:

  • 'expanded' dates, which have year numbers of greater than 4 digits, and may be negative; in openEHR, only 4-digit year numbers are assumed;

  • the YYYY-"W"WW-D method of expressing dates (since this is imprecise and difficult to compute with due to variable week starting dates, and not required in health);

  • partial date/times with fractional minutes or hours, e.g. hh,hhh or mm,mm; in openEHR, only fractional seconds are supported;

  • the interval syntax. Intervals of date/times are supported in openEHR, but their syntax form is defined by ADL, and is standardised across all comparable types, not just dates and times.

Deviations from the published standard include the following.

  • Durations are supposed to take the form of PnnW or PnnYnnMnnDTnnHnnMnnS, but in openEHR, the W (week) designator can be used in combination with the other designators, since it is very common to state durations of pregnancy as some combination of weeks and days.

  • Durations in openEHR may take a negative sign, indicating a duration prior to an origin. This supports healthcare needs such as 'adjusted age' (e.g. '-P3M', an age of 'minus 3 months') for very premature newborns.

  • Partial variants of Iso8601_date_time can include missing hours, days and months, whereas ISO 8601:2019 (section 4.3.3 c) only allows missing seconds and minutes. The reasons for this deviation are:

    • the same deviation is used in HL7v2 and HL7v3 TS (timestamp) type, i.e. there are data in existing clinical systems matching this specification;

    • in a typed object model, this deviation is more sensible anyway; the ISO 8601 rule is most likely a limitation of the purely syntactic means of expression. In real systems where a timestamp/date-time is specified in a screen form, it makes sense to allow it to be as partial as possible, rather than artificially restricted to only missing seconds and minutes.

  • The time 24:00:00 (or 240000) is not allowed anywhere, whereas in ISO 8601:2019 it appears to be legal at least for pure times. This deviation is also appears to be used in HL7v2 and HL7v3 (where midnight is defined as the time 00:00:00), and is preferable to the documented standard, since a date/time with time of 24:00:00 is really the next day, i.e. the date part is then incorrect.

Negation for ISO 8601 durations is also supported by W3C XML-schema and various programming languages. See Wikipedia and the official ISO 8601 standard for details. Note that in the date, time and date/time formats shown below, 'Z' and 'T' are literals. In the duration class shown below, 'P', 'Y', 'M', 'W', 'D', 'H', 'S' and 'T' are literals.

Derived Interval / Time Types

A number of useful types may be generated from the Date/time classes and the Interval classes. These are shown in blue on the following diagram.

BASE foundation types.time intervals
Figure 2. Useful time interval types

Computational Functions

A number of computational functions are defined in the interfaces of the concrete data/time types, of two kinds:

  • definite: computed according to the usual numeric rules for arithmetic, in which all values are treated as definite, i.e. exact and invariant;

  • nominal: computed using commonly accepted rules of 'everyday' calendrical time, in which 'year' and 'month' are understood to be variable periods.

Most of the functions defined on the date/time types are of the definite kind. The exception is functions involving Iso8601_duration values, which take both definite and nominal forms. The definite forms are named using the standard names add(), subtract() etc, while the nominal versions have names of the form xxx_nominal(), e.g. add_nominal() etc.

An example of an operation having both forms is addition for the type Iso8601_date. The definite operation is called add() and treats the Iso8601_duration argument as an exact amount, based on constant values for length of year and month, defined by Time_definitions.Average_days_in_month and Time_definitions.Average_days_in_year.

The nominal form of the operation is add_nominal(), and is computed according to 'everyday' rules, i.e. in which the phrase 'a year from now' means the same date next year (with occasional slight adjustment), and 'in a month' means the same date next month (or possibly a day or earlier due to next month being shorter). In a similar way, the addition of a period of one day ('P1D'), although itself a regular quantity is computed differently to the definite form: in the definite form, addition of P1D results in the addition of exactly 24h of time to the date, which may result in a time that is different by one hour due to a change of summer time during the interval, while the nominal addition results in the same time on the next of previous day, even though occasionally this will represent 23 or 25 hours' difference.

The definite functions have standard operators such as '+', '-', etc. associated with them, while the nominal functions have the operators '++', '--', etc.

Class Definitions

Time_Definitions Class

  • Definition

  • Effective

  • BMM

  • UML

Class

Time_Definitions

Description

Definitions for date/time classes. Note that the timezone limits are set by where the international dateline is. Thus, time in New Zealand is quoted using +12:00, not -12:00.

Constants

Signature

Meaning

1..1

Seconds_in_minute: Integer = 60

Number of seconds in a minute.

1..1

Minutes_in_hour: Integer = 60

Number of minutes in an hour.

1..1

Hours_in_day: Integer = 24

Number of clock hours in a day, i.e. 24.

1..1

Average_days_in_month: Real = 30.42

Used for conversions of durations containing months to days and / or seconds.

1..1

Max_days_in_month: Integer = 31

Maximum number of days in any month.

1..1

Days_in_year: Integer = 365

Calendar days in a normal year, i.e. 365.

1..1

Average_days_in_year: Real = 365.24

Used for conversions of durations containing years to days and / or seconds.

1..1

Days_in_leap_year: Integer = 366

Calendar days in a standard leap year, i.e. 366.

1..1

Max_days_in_year: Integer = Days_in_leap_year

Maximum number of days in a year, i.e. accounting for leap years.

1..1

Days_in_week: Integer = 7

Number of days in a week.

1..1

Months_in_year: Integer = 12

Number of months in a year.

1..1

Min_timezone_hour: Integer = 12

Minimum hour value of a timezone according to ISO 8601 (note that the -ve sign is supplied in the ISO8601_TIMEZONE class).

1..1

Max_timezone_hour: Integer = 14

Maximum hour value of a timezone according to ISO 8601.

1..1

Nominal_days_in_month: Real = 30.42

Used for conversions of durations containing months to days and / or seconds.

1..1

Nominal_days_in_year: Real = 365.24

Used for conversions of durations containing years to days and / or seconds.

Functions

Signature

Meaning

1..1

valid_year (
y: Integer[1]
): Boolean

Post: Result = y >= 0

True if y >= 0.

1..1

valid_month (
m: Integer[1]
): Boolean

Post: Result = m >= 1 and m <= Months_in_year

True if m >= 1 and m <= months_in_year.

1..1

valid_day (
y: Integer[1],
m: Integer[1],
d: Integer[1]
): Boolean

Post: Result = d >= 1 and d <= days_in_month (m, y)

True if d >= 1 and d <= days_in_month (m, y).

1..1

valid_hour (
h: Integer[1],
m: Integer[1],
s: Integer[1]
): Boolean

Post: Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0)

True if (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) .

1..1

valid_minute (
m: Integer[1]
): Boolean

Post: Result = m >= 0 and m < Minutes_in_hour

True if m >= 0 and m < Minutes_in_hour.

1..1

valid_second (
s: Integer[1]
): Boolean

Post: Result = s >= 0 and s < Seconds_in_minute

True if s >= 0 and s < Seconds_in_minute .

1..1

valid_fractional_second (
fs: Double[1]
): Boolean

Post: Result = fs >= 0.0 and fs < 1.0

True if fs >= 0.0 and fs < 1.0 .

1..1

valid_iso8601_date (
s: String[1]
): Boolean

String is a valid ISO 8601 date, i.e. takes the complete form:

  • YYYY-MM-DD (extended, preferred) or one of the partial forms YYYY-MM or YYYY

  • YYYYMMDD (compact) or a partial variant YYYYMM.

Where:

  • YYYY is the string form of any positive number in the range 0000 - 9999 (zero-filled to four digits)

  • MM is 01 - 12 (zero-filled to two digits)

  • DD is 01 - 31 (zero-filled to two digits)

The combinations of YYYY, MM, DD numbers must be correct with respect to the Gregorian calendar.

1..1

valid_iso8601_time (
s: String[1]
): Boolean

String is a valid ISO 8601 date, i.e. takes the form:

  • hh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • hhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • hh:mm (extended)

    • hhmm or hh (compact)

with an additional optional timezone indicator of:

  • Z or ±hh[:mm] (extended) ±hh[mm] (compact)

Where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • ss is "00" - "60" (0-filled to two digits)

  • [(,|.)s+] is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

1..1

valid_iso8601_date_time (
s: String[1]
): Boolean

String is a valid ISO 8601 date-time, i.e. takes the form:

  • YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • YYYY-MM-DDThh:mm or YYYY-MM-DDThh (extended)

    • YYYYMMDDThhmm or YYYYMMDDThh (compact)

1..1

valid_iso8601_duration (
s: String[1]
): Boolean

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7-day weeks.

Note: allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

Parameters
s

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7- day weeks.

allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).
Time_Definitions

Definitions for date/time classes. Note that the timezone limits are set by where the international dateline is. Thus, time in New Zealand is quoted using +12:00, not -12:00.

Constants

Seconds_in_minute: Integer = 60 [1..1]

Number of seconds in a minute.

Minutes_in_hour: Integer = 60 [1..1]

Number of minutes in an hour.

Hours_in_day: Integer = 24 [1..1]

Number of clock hours in a day, i.e. 24.

Average_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Max_days_in_month: Integer = 31 [1..1]

Maximum number of days in any month.

Days_in_year: Integer = 365 [1..1]

Calendar days in a normal year, i.e. 365.

Average_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Days_in_leap_year: Integer = 366 [1..1]

Calendar days in a standard leap year, i.e. 366.

Max_days_in_year: Integer = Days_in_leap_year [1..1]

Maximum number of days in a year, i.e. accounting for leap years.

Days_in_week: Integer = 7 [1..1]

Number of days in a week.

Months_in_year: Integer = 12 [1..1]

Number of months in a year.

Min_timezone_hour: Integer = 12 [1..1]

Minimum hour value of a timezone according to ISO 8601 (note that the -ve sign is supplied in the ISO8601_TIMEZONE class).

Max_timezone_hour: Integer = 14 [1..1]

Maximum hour value of a timezone according to ISO 8601.

Nominal_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Nominal_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Functions

valid_year (
y: Integer[1]
): Boolean

Post: Result = y >= 0 [1..1]

True if y >= 0.

valid_month (
m: Integer[1]
): Boolean

Post: Result = m >= 1 and m <= Months_in_year [1..1]

True if m >= 1 and m <= months_in_year.

valid_day (
y: Integer[1],
m: Integer[1],
d: Integer[1]
): Boolean

Post: Result = d >= 1 and d <= days_in_month (m, y) [1..1]

True if d >= 1 and d <= days_in_month (m, y).

valid_hour (
h: Integer[1],
m: Integer[1],
s: Integer[1]
): Boolean

Post: Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) [1..1]

True if (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) .

valid_minute (
m: Integer[1]
): Boolean

Post: Result = m >= 0 and m < Minutes_in_hour [1..1]

True if m >= 0 and m < Minutes_in_hour.

valid_second (
s: Integer[1]
): Boolean

Post: Result = s >= 0 and s < Seconds_in_minute [1..1]

True if s >= 0 and s < Seconds_in_minute .

valid_fractional_second (
fs: Double[1]
): Boolean

Post: Result = fs >= 0.0 and fs < 1.0 [1..1]

True if fs >= 0.0 and fs < 1.0 .

valid_iso8601_date (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the complete form:

  • YYYY-MM-DD (extended, preferred) or one of the partial forms YYYY-MM or YYYY

  • YYYYMMDD (compact) or a partial variant YYYYMM.

Where:

  • YYYY is the string form of any positive number in the range 0000 - 9999 (zero-filled to four digits)

  • MM is 01 - 12 (zero-filled to two digits)

  • DD is 01 - 31 (zero-filled to two digits)

The combinations of YYYY, MM, DD numbers must be correct with respect to the Gregorian calendar.

valid_iso8601_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the form:

  • hh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • hhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • hh:mm (extended)

    • hhmm or hh (compact)

with an additional optional timezone indicator of:

  • Z or ±hh[:mm] (extended) ±hh[mm] (compact)

Where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • ss is "00" - "60" (0-filled to two digits)

  • [(,|.)s+] is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

valid_iso8601_date_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date-time, i.e. takes the form:

  • YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • YYYY-MM-DDThh:mm or YYYY-MM-DDThh (extended)

    • YYYYMMDDThhmm or YYYYMMDDThh (compact)

valid_iso8601_duration (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7-day weeks.

Note: allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

Parameters
s

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7- day weeks.

allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).
{
    "name": "Time_Definitions",
    "documentation": "Definitions for date/time classes. Note that the timezone limits are set by where the international dateline is. Thus, time in New Zealand is quoted using `+12:00`, not `-12:00`.",
    "constants": {
        "Seconds_in_minute": {
            "name": "Seconds_in_minute",
            "documentation": "Number of seconds in a minute.",
            "type": "Integer",
            "value": 60
        },
        "Minutes_in_hour": {
            "name": "Minutes_in_hour",
            "documentation": "Number of minutes in an hour.",
            "type": "Integer",
            "value": 60
        },
        "Hours_in_day": {
            "name": "Hours_in_day",
            "documentation": "Number of clock hours in a day, i.e. 24.",
            "type": "Integer",
            "value": 24
        },
        "Average_days_in_month": {
            "name": "Average_days_in_month",
            "documentation": "Used for conversions of durations containing months to days and / or seconds.",
            "type": "Real",
            "value": 30.42
        },
        "Max_days_in_month": {
            "name": "Max_days_in_month",
            "documentation": "Maximum number of days in any month.",
            "type": "Integer",
            "value": 31
        },
        "Days_in_year": {
            "name": "Days_in_year",
            "documentation": "Calendar days in a normal year, i.e. 365.",
            "type": "Integer",
            "value": 365
        },
        "Average_days_in_year": {
            "name": "Average_days_in_year",
            "documentation": "Used for conversions of durations containing years to days and / or seconds.",
            "type": "Real",
            "value": 365.24
        },
        "Days_in_leap_year": {
            "name": "Days_in_leap_year",
            "documentation": "Calendar days in a standard leap year, i.e. 366.",
            "type": "Integer",
            "value": 366
        },
        "Max_days_in_year": {
            "name": "Max_days_in_year",
            "documentation": "Maximum number of days in a year, i.e. accounting for leap years.",
            "type": "Integer",
            "value": "Days_in_leap_year"
        },
        "Days_in_week": {
            "name": "Days_in_week",
            "documentation": "Number of days in a week.",
            "type": "Integer",
            "value": 7
        },
        "Months_in_year": {
            "name": "Months_in_year",
            "documentation": "Number of months in a year.",
            "type": "Integer",
            "value": 12
        },
        "Min_timezone_hour": {
            "name": "Min_timezone_hour",
            "documentation": "Minimum hour value of a timezone  according to ISO 8601 (note that the -ve sign is supplied in the `ISO8601_TIMEZONE` class).",
            "type": "Integer",
            "value": 12
        },
        "Max_timezone_hour": {
            "name": "Max_timezone_hour",
            "documentation": "Maximum hour value of a timezone according to ISO 8601.",
            "type": "Integer",
            "value": 14
        },
        "Nominal_days_in_month": {
            "name": "Nominal_days_in_month",
            "documentation": "Used for conversions of durations containing months to days and / or seconds.",
            "type": "Real",
            "value": 30.42
        },
        "Nominal_days_in_year": {
            "name": "Nominal_days_in_year",
            "documentation": "Used for conversions of durations containing years to days and / or seconds.",
            "type": "Real",
            "value": 365.24
        }
    },
    "functions": {
        "valid_year": {
            "name": "valid_year",
            "documentation": "True if `y >= 0`.",
            "parameters": {
                "y": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "y",
                    "type": "Integer"
                }
            },
            "post_conditions": {
                "Post": "Result = y >= 0"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_month": {
            "name": "valid_month",
            "documentation": "True if `m >= 1 and m <= months_in_year`.",
            "parameters": {
                "m": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "m",
                    "type": "Integer"
                }
            },
            "post_conditions": {
                "Post": "Result = m >= 1 and m <= Months_in_year"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_day": {
            "name": "valid_day",
            "documentation": "True if `d >= 1 and d <= days_in_month (m, y)`.",
            "parameters": {
                "y": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "y",
                    "type": "Integer"
                },
                "m": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "m",
                    "type": "Integer"
                },
                "d": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "d",
                    "type": "Integer"
                }
            },
            "post_conditions": {
                "Post": "Result = d >= 1 and d <= days_in_month (m, y)"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_hour": {
            "name": "valid_hour",
            "documentation": "True if `(h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0)` .",
            "parameters": {
                "h": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "h",
                    "type": "Integer"
                },
                "m": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "m",
                    "type": "Integer"
                },
                "s": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "s",
                    "type": "Integer"
                }
            },
            "post_conditions": {
                "Post": "Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0)"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_minute": {
            "name": "valid_minute",
            "documentation": "True if `m >= 0 and m < Minutes_in_hour`.",
            "parameters": {
                "m": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "m",
                    "type": "Integer"
                }
            },
            "post_conditions": {
                "Post": "Result = m >= 0 and m < Minutes_in_hour"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_second": {
            "name": "valid_second",
            "documentation": "True if `s >= 0 and s < Seconds_in_minute` .",
            "parameters": {
                "s": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "s",
                    "type": "Integer"
                }
            },
            "post_conditions": {
                "Post": "Result = s >= 0 and s < Seconds_in_minute"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_fractional_second": {
            "name": "valid_fractional_second",
            "documentation": "True if `fs >= 0.0` and `fs < 1.0` .",
            "parameters": {
                "fs": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "fs",
                    "type": "Double"
                }
            },
            "post_conditions": {
                "Post": "Result = fs >= 0.0 and fs < 1.0"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_iso8601_date": {
            "name": "valid_iso8601_date",
            "documentation": "String is a valid ISO 8601 date, i.e. takes the complete form:\n\n* `YYYY-MM-DD` (extended, preferred) or one of the partial forms `YYYY-MM` or `YYYY`\n* `YYYYMMDD` (compact) or a partial variant `YYYYMM`.\n\nWhere:\n\n* `YYYY` is the string form of any positive number in the range `0000` - `9999` (zero-filled to four digits)\n* `MM` is `01` - `12` (zero-filled to two digits)\n* `DD` is `01` - `31` (zero-filled to two digits)\n\nThe combinations of `YYYY`, `MM`, `DD` numbers must be correct with respect to the Gregorian calendar.",
            "parameters": {
                "s": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "s",
                    "type": "String"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_iso8601_time": {
            "name": "valid_iso8601_time",
            "documentation": "String is a valid ISO 8601 date, i.e. takes the form:\n\n* `hh:mm:ss[(,|.)s+][Z|±hh[:mm]]` (extended)\n* `hhmmss[(,|.)s+][Z|±hh[mm]]` (compact)\n* or one of the partial forms:\n** `hh:mm` (extended)\n** `hhmm` or `hh` (compact)\n\nwith an additional optional timezone indicator of:\n\n* `Z` or `±hh[:mm]` (extended)  `±hh[mm]` (compact)\n\nWhere:\n\n* `hh` is \"00\" - \"23\" (0-filled to two digits)\n* `mm` is \"00\" - \"59\" (0-filled to two digits)\n* `ss` is \"00\" - \"60\" (0-filled to two digits)\n* `[(,|.)s+]` is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second\n* `Z` is a literal meaning UTC (modern replacement for GMT), i.e. timezone `+0000`\n",
            "parameters": {
                "s": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "s",
                    "type": "String"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_iso8601_date_time": {
            "name": "valid_iso8601_date_time",
            "documentation": "String is a valid ISO 8601 date-time, i.e. takes the form:\n\n* `YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]]` (extended)\n* `YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]]` (compact)\n* or one of the partial forms:\n** `YYYY-MM-DDThh:mm` or `YYYY-MM-DDThh` (extended)\n** `YYYYMMDDThhmm` or `YYYYMMDDThh` (compact)",
            "parameters": {
                "s": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "s",
                    "type": "String"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "valid_iso8601_duration": {
            "name": "valid_iso8601_duration",
            "documentation": "String is a valid ISO 8601 duration, i.e. takes the form:\n\n* `P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]`\n\nWhere each nn represents a number of years, months, etc. `nnW` represents a number of 7-day weeks.\n\nNote: allowing the `W` designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).",
            "parameters": {
                "s": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "s",
                    "documentation": "String is a valid ISO 8601 duration, i.e. takes the form:\n\n* `P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]`\n\nWhere each `nn` represents a number of years, months, etc. `nnW` represents a number of 7- day weeks.\n\nNOTE: allowing the `W` designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).",
                    "type": "String"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        }
    }
}
Time_Definitions

Temporal Class

  • Definition

  • Effective

  • BMM

  • UML

Class

Temporal (abstract)

Description

Abstract ancestor of time-related classes.

Inherit

Ordered

Temporal (abstract)

Abstract ancestor of time-related classes.

Inherits: Any, Ordered

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

Any.equal alias "=", "==" (
other: Any[1]
): Boolean [1..1]

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

Type name of an object as a string. May include generic parameters, as in "Interval<Time>".

Any.not_equal alias "!=", "≠" (
other: Ordered[1]
): Boolean [1..1]

True if current object not equal to other. Returns not equal().

(abstract) Ordered.less_than alias "<" (
other: Ordered[1]
): Boolean [1..1]

Arithmetic value comparison. Returns True if current object is less than other. This operator is effected and/or redefined in descendants to provide the appropriate ordering semantics for concrete types.

In conjunction with =, enables the definition of the related functions greater_than() etc.

Ordered.less_than_or_equal alias "⇐", "≤" (
other: Ordered[1]
): Boolean

Post_result: not (other < self) [1..1]

True if current object less than or equal to other.

Ordered.greater_than alias ">" (
other: Ordered[1]
): Boolean

Post_result: Result = (other < self) [1..1]

True if current object greater than other.

Ordered.greater_than_or_equal alias ">=", "≥" (
other: Ordered[1]
): Boolean

Post_result: Result = (other <= self) [1..1]

True if current object greater than or equal to other.

{
    "name": "Temporal",
    "documentation": "Abstract ancestor of time-related classes.",
    "is_abstract": true,
    "ancestors": [
        "Ordered"
    ]
}
Temporal

Iso8601_type Class

  • Definition

  • Effective

  • BMM

  • UML

Class

Iso8601_type (abstract)

Description

Abstract ancestor type of ISO 8601 types, defining interface for 'extended' and 'partial' concepts from ISO 8601.

Inherit

Temporal, Time_Definitions

Attributes

Signature

Meaning

1..1

value: String

Representation of all descendants is a single String.

Functions

Signature

Meaning

1..1
(abstract)

is_partial (): Boolean

True if this date time is partial, i.e. if trailing end (right hand) value(s) is/are missing.

1..1
(abstract)

is_extended (): Boolean

True if this ISO8601 string is in the 'extended' form, i.e. uses '-' and / or ':' separators. This is the preferred format.

Iso8601_type (abstract)

Abstract ancestor type of ISO 8601 types, defining interface for 'extended' and 'partial' concepts from ISO 8601.

Inherits: Any, Ordered, Temporal, Time_Definitions

Constants

Time_Definitions.Seconds_in_minute: Integer = 60 [1..1]

Number of seconds in a minute.

Time_Definitions.Minutes_in_hour: Integer = 60 [1..1]

Number of minutes in an hour.

Time_Definitions.Hours_in_day: Integer = 24 [1..1]

Number of clock hours in a day, i.e. 24.

Time_Definitions.Average_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Max_days_in_month: Integer = 31 [1..1]

Maximum number of days in any month.

Time_Definitions.Days_in_year: Integer = 365 [1..1]

Calendar days in a normal year, i.e. 365.

Time_Definitions.Average_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Time_Definitions.Days_in_leap_year: Integer = 366 [1..1]

Calendar days in a standard leap year, i.e. 366.

Time_Definitions.Max_days_in_year: Integer = Days_in_leap_year [1..1]

Maximum number of days in a year, i.e. accounting for leap years.

Time_Definitions.Days_in_week: Integer = 7 [1..1]

Number of days in a week.

Time_Definitions.Months_in_year: Integer = 12 [1..1]

Number of months in a year.

Time_Definitions.Min_timezone_hour: Integer = 12 [1..1]

Minimum hour value of a timezone according to ISO 8601 (note that the -ve sign is supplied in the ISO8601_TIMEZONE class).

Time_Definitions.Max_timezone_hour: Integer = 14 [1..1]

Maximum hour value of a timezone according to ISO 8601.

Time_Definitions.Nominal_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Nominal_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Attributes

value: String [1..1]

Representation of all descendants is a single String.

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

Any.equal alias "=", "==" (
other: Any[1]
): Boolean [1..1]

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

Type name of an object as a string. May include generic parameters, as in "Interval<Time>".

Any.not_equal alias "!=", "≠" (
other: Ordered[1]
): Boolean [1..1]

True if current object not equal to other. Returns not equal().

(abstract) Ordered.less_than alias "<" (
other: Ordered[1]
): Boolean [1..1]

Arithmetic value comparison. Returns True if current object is less than other. This operator is effected and/or redefined in descendants to provide the appropriate ordering semantics for concrete types.

In conjunction with =, enables the definition of the related functions greater_than() etc.

Ordered.less_than_or_equal alias "⇐", "≤" (
other: Ordered[1]
): Boolean

Post_result: not (other < self) [1..1]

True if current object less than or equal to other.

Ordered.greater_than alias ">" (
other: Ordered[1]
): Boolean

Post_result: Result = (other < self) [1..1]

True if current object greater than other.

Ordered.greater_than_or_equal alias ">=", "≥" (
other: Ordered[1]
): Boolean

Post_result: Result = (other <= self) [1..1]

True if current object greater than or equal to other.

Time_Definitions.valid_year (
y: Integer[1]
): Boolean

Post: Result = y >= 0 [1..1]

True if y >= 0.

Time_Definitions.valid_month (
m: Integer[1]
): Boolean

Post: Result = m >= 1 and m <= Months_in_year [1..1]

True if m >= 1 and m <= months_in_year.

Time_Definitions.valid_day (
y: Integer[1],
m: Integer[1],
d: Integer[1]
): Boolean

Post: Result = d >= 1 and d <= days_in_month (m, y) [1..1]

True if d >= 1 and d <= days_in_month (m, y).

Time_Definitions.valid_hour (
h: Integer[1],
m: Integer[1],
s: Integer[1]
): Boolean

Post: Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) [1..1]

True if (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) .

Time_Definitions.valid_minute (
m: Integer[1]
): Boolean

Post: Result = m >= 0 and m < Minutes_in_hour [1..1]

True if m >= 0 and m < Minutes_in_hour.

Time_Definitions.valid_second (
s: Integer[1]
): Boolean

Post: Result = s >= 0 and s < Seconds_in_minute [1..1]

True if s >= 0 and s < Seconds_in_minute .

Time_Definitions.valid_fractional_second (
fs: Double[1]
): Boolean

Post: Result = fs >= 0.0 and fs < 1.0 [1..1]

True if fs >= 0.0 and fs < 1.0 .

Time_Definitions.valid_iso8601_date (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the complete form:

  • YYYY-MM-DD (extended, preferred) or one of the partial forms YYYY-MM or YYYY

  • YYYYMMDD (compact) or a partial variant YYYYMM.

Where:

  • YYYY is the string form of any positive number in the range 0000 - 9999 (zero-filled to four digits)

  • MM is 01 - 12 (zero-filled to two digits)

  • DD is 01 - 31 (zero-filled to two digits)

The combinations of YYYY, MM, DD numbers must be correct with respect to the Gregorian calendar.

Time_Definitions.valid_iso8601_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the form:

  • hh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • hhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • hh:mm (extended)

    • hhmm or hh (compact)

with an additional optional timezone indicator of:

  • Z or ±hh[:mm] (extended) ±hh[mm] (compact)

Where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • ss is "00" - "60" (0-filled to two digits)

  • [(,|.)s+] is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

Time_Definitions.valid_iso8601_date_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date-time, i.e. takes the form:

  • YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • YYYY-MM-DDThh:mm or YYYY-MM-DDThh (extended)

    • YYYYMMDDThhmm or YYYYMMDDThh (compact)

Time_Definitions.valid_iso8601_duration (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7-day weeks.

Note: allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

Parameters
s

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7- day weeks.

allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

(abstract) is_partial (): Boolean [1..1]

True if this date time is partial, i.e. if trailing end (right hand) value(s) is/are missing.

(abstract) is_extended (): Boolean [1..1]

True if this ISO8601 string is in the 'extended' form, i.e. uses '-' and / or ':' separators. This is the preferred format.

{
    "name": "Iso8601_type",
    "documentation": "Abstract ancestor type of ISO 8601 types, defining interface for 'extended' and 'partial' concepts from ISO 8601.",
    "is_abstract": true,
    "ancestors": [
        "Temporal",
        "Time_Definitions"
    ],
    "properties": {
        "value": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "value",
            "documentation": "Representation of all descendants is a single String.",
            "is_mandatory": true,
            "type": "String"
        }
    },
    "functions": {
        "is_partial": {
            "name": "is_partial",
            "documentation": "True if this date time is partial, i.e. if trailing end (right hand) value(s) is/are missing.",
            "is_abstract": true,
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_extended": {
            "name": "is_extended",
            "documentation": "True if this ISO8601 string is in the 'extended' form, i.e. uses `'-'` and / or `':'` separators. This is the preferred format.",
            "is_abstract": true,
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        }
    }
}
Iso8601_type

Iso8601_date Class

  • Definition

  • Effective

  • BMM

  • UML

Class

Iso8601_date

Description

Represents an ISO 8601 date, including partial and extended forms. Value may be:

  • YYYY-MM-DD (extended, preferred)

  • YYYYMMDD (compact)

  • a partial invariant.

See Time_definitions.valid_iso8601_date() for validity.

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1

year (): Integer

Extract the year part of the date as an Integer.

1..1

month (): Integer

Pre: not month_unknown

Extract the month part of the date as an Integer, or return 0 if not present.

1..1

day (): Integer

Pre: not day_unknown

Extract the day part of the date as an Integer, or return 0 if not present.

1..1

timezone (): Iso8601_timezone

Timezone; may be Void.

1..1

month_unknown (): Boolean

Indicates whether month in year is unknown. If so, the date is of the form "YYYY".

1..1

day_unknown (): Boolean

Indicates whether day in month is unknown. If so, and month is known, the date is of the form "YYYY-MM" or "YYYYMM".

1..1
(effected)

is_partial (): Boolean

True if this date is partial, i.e. if days or more is missing.

1..1
(effected)

is_extended (): Boolean

True if this date uses '-' separators.

1..1

as_string (): String

Return string value in extended format.

1..1

add alias "+" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Arithmetic addition of a duration to a date.

1..1

subtract alias "-" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Arithmetic subtraction of a duration from a date.

1..1

diff alias "-" (
a_date: Iso8601_date[1]
): Iso8601_duration

Difference of two dates.

1..1

add_nominal alias "++" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Addition of nominal duration represented by a_diff. For example, a duration of 'P1Y' means advance to the same date next year, with the exception of the date 29 February in a leap year, to which the addition of a nominal year will result in 28 February of the following year. Similarly, 'P1M' is understood here as a nominal month, the addition of which will result in one of:

  • the same day in the following month, if it exists, or;

  • one or two days less where the following month is shorter, or;

  • in the case of adding a month to the date 31 Jan, the result will be 28 Feb in a non-leap year (i.e. three less) and 29 Feb in a leap year (i.e. two less).

1..1

subtract_nominal alias "--" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Subtraction of nominal duration represented by a_diff. See add_nominal() for semantics.

Invariants

Year_valid: valid_year (year)

Month_valid: not month_unknown implies valid_month (month)

Day_valid: not day_unknown implies valid_day (year, month, day)

Partial_validity: month_unknown implies day_unknown

Iso8601_date

Represents an ISO 8601 date, including partial and extended forms. Value may be:

  • YYYY-MM-DD (extended, preferred)

  • YYYYMMDD (compact)

  • a partial invariant.

See Time_definitions.valid_iso8601_date() for validity.

Inherits: Any, Ordered, Temporal, Time_Definitions, Iso8601_type

Constants

Time_Definitions.Seconds_in_minute: Integer = 60 [1..1]

Number of seconds in a minute.

Time_Definitions.Minutes_in_hour: Integer = 60 [1..1]

Number of minutes in an hour.

Time_Definitions.Hours_in_day: Integer = 24 [1..1]

Number of clock hours in a day, i.e. 24.

Time_Definitions.Average_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Max_days_in_month: Integer = 31 [1..1]

Maximum number of days in any month.

Time_Definitions.Days_in_year: Integer = 365 [1..1]

Calendar days in a normal year, i.e. 365.

Time_Definitions.Average_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Time_Definitions.Days_in_leap_year: Integer = 366 [1..1]

Calendar days in a standard leap year, i.e. 366.

Time_Definitions.Max_days_in_year: Integer = Days_in_leap_year [1..1]

Maximum number of days in a year, i.e. accounting for leap years.

Time_Definitions.Days_in_week: Integer = 7 [1..1]

Number of days in a week.

Time_Definitions.Months_in_year: Integer = 12 [1..1]

Number of months in a year.

Time_Definitions.Min_timezone_hour: Integer = 12 [1..1]

Minimum hour value of a timezone according to ISO 8601 (note that the -ve sign is supplied in the ISO8601_TIMEZONE class).

Time_Definitions.Max_timezone_hour: Integer = 14 [1..1]

Maximum hour value of a timezone according to ISO 8601.

Time_Definitions.Nominal_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Nominal_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Attributes

Iso8601_type.value: String [1..1]

Representation of all descendants is a single String.

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

Any.equal alias "=", "==" (
other: Any[1]
): Boolean [1..1]

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

Type name of an object as a string. May include generic parameters, as in "Interval<Time>".

Any.not_equal alias "!=", "≠" (
other: Ordered[1]
): Boolean [1..1]

True if current object not equal to other. Returns not equal().

(abstract) Ordered.less_than alias "<" (
other: Ordered[1]
): Boolean [1..1]

Arithmetic value comparison. Returns True if current object is less than other. This operator is effected and/or redefined in descendants to provide the appropriate ordering semantics for concrete types.

In conjunction with =, enables the definition of the related functions greater_than() etc.

Ordered.less_than_or_equal alias "⇐", "≤" (
other: Ordered[1]
): Boolean

Post_result: not (other < self) [1..1]

True if current object less than or equal to other.

Ordered.greater_than alias ">" (
other: Ordered[1]
): Boolean

Post_result: Result = (other < self) [1..1]

True if current object greater than other.

Ordered.greater_than_or_equal alias ">=", "≥" (
other: Ordered[1]
): Boolean

Post_result: Result = (other <= self) [1..1]

True if current object greater than or equal to other.

Time_Definitions.valid_year (
y: Integer[1]
): Boolean

Post: Result = y >= 0 [1..1]

True if y >= 0.

Time_Definitions.valid_month (
m: Integer[1]
): Boolean

Post: Result = m >= 1 and m <= Months_in_year [1..1]

True if m >= 1 and m <= months_in_year.

Time_Definitions.valid_day (
y: Integer[1],
m: Integer[1],
d: Integer[1]
): Boolean

Post: Result = d >= 1 and d <= days_in_month (m, y) [1..1]

True if d >= 1 and d <= days_in_month (m, y).

Time_Definitions.valid_hour (
h: Integer[1],
m: Integer[1],
s: Integer[1]
): Boolean

Post: Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) [1..1]

True if (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) .

Time_Definitions.valid_minute (
m: Integer[1]
): Boolean

Post: Result = m >= 0 and m < Minutes_in_hour [1..1]

True if m >= 0 and m < Minutes_in_hour.

Time_Definitions.valid_second (
s: Integer[1]
): Boolean

Post: Result = s >= 0 and s < Seconds_in_minute [1..1]

True if s >= 0 and s < Seconds_in_minute .

Time_Definitions.valid_fractional_second (
fs: Double[1]
): Boolean

Post: Result = fs >= 0.0 and fs < 1.0 [1..1]

True if fs >= 0.0 and fs < 1.0 .

Time_Definitions.valid_iso8601_date (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the complete form:

  • YYYY-MM-DD (extended, preferred) or one of the partial forms YYYY-MM or YYYY

  • YYYYMMDD (compact) or a partial variant YYYYMM.

Where:

  • YYYY is the string form of any positive number in the range 0000 - 9999 (zero-filled to four digits)

  • MM is 01 - 12 (zero-filled to two digits)

  • DD is 01 - 31 (zero-filled to two digits)

The combinations of YYYY, MM, DD numbers must be correct with respect to the Gregorian calendar.

Time_Definitions.valid_iso8601_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the form:

  • hh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • hhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • hh:mm (extended)

    • hhmm or hh (compact)

with an additional optional timezone indicator of:

  • Z or ±hh[:mm] (extended) ±hh[mm] (compact)

Where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • ss is "00" - "60" (0-filled to two digits)

  • [(,|.)s+] is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

Time_Definitions.valid_iso8601_date_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date-time, i.e. takes the form:

  • YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • YYYY-MM-DDThh:mm or YYYY-MM-DDThh (extended)

    • YYYYMMDDThhmm or YYYYMMDDThh (compact)

Time_Definitions.valid_iso8601_duration (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7-day weeks.

Note: allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

Parameters
s

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7- day weeks.

allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

is_partial (): Boolean [1..1]

True if this date is partial, i.e. if days or more is missing.

is_extended (): Boolean [1..1]

True if this date uses '-' separators.

year (): Integer [1..1]

Extract the year part of the date as an Integer.

month (): Integer

Pre: not month_unknown [1..1]

Extract the month part of the date as an Integer, or return 0 if not present.

day (): Integer

Pre: not day_unknown [1..1]

Extract the day part of the date as an Integer, or return 0 if not present.

timezone (): Iso8601_timezone [1..1]

Timezone; may be Void.

month_unknown (): Boolean [1..1]

Indicates whether month in year is unknown. If so, the date is of the form "YYYY".

day_unknown (): Boolean [1..1]

Indicates whether day in month is unknown. If so, and month is known, the date is of the form "YYYY-MM" or "YYYYMM".

as_string (): String [1..1]

Return string value in extended format.

add alias "+" (
a_diff: Iso8601_duration[1]
): Iso8601_date [1..1]

Arithmetic addition of a duration to a date.

subtract alias "-" (
a_diff: Iso8601_duration[1]
): Iso8601_date [1..1]

Arithmetic subtraction of a duration from a date.

diff alias "-" (
a_date: Iso8601_date[1]
): Iso8601_duration [1..1]

Difference of two dates.

add_nominal alias "++" (
a_diff: Iso8601_duration[1]
): Iso8601_date [1..1]

Addition of nominal duration represented by a_diff. For example, a duration of 'P1Y' means advance to the same date next year, with the exception of the date 29 February in a leap year, to which the addition of a nominal year will result in 28 February of the following year. Similarly, 'P1M' is understood here as a nominal month, the addition of which will result in one of:

  • the same day in the following month, if it exists, or;

  • one or two days less where the following month is shorter, or;

  • in the case of adding a month to the date 31 Jan, the result will be 28 Feb in a non-leap year (i.e. three less) and 29 Feb in a leap year (i.e. two less).

subtract_nominal alias "--" (
a_diff: Iso8601_duration[1]
): Iso8601_date [1..1]

Subtraction of nominal duration represented by a_diff. See add_nominal() for semantics.

Invariants

Year_valid: valid_year (year)

Month_valid: not month_unknown implies valid_month (month)

Day_valid: not day_unknown implies valid_day (year, month, day)

Partial_validity: month_unknown implies day_unknown

{
    "name": "Iso8601_date",
    "documentation": "Represents an ISO 8601 date, including partial and extended forms. Value may be:\n\n* `YYYY-MM-DD` (extended, preferred)\n* `YYYYMMDD` (compact)\n* a partial invariant.\n\nSee `Time_definitions._valid_iso8601_date()_` for validity.",
    "ancestors": [
        "Iso8601_type"
    ],
    "functions": {
        "year": {
            "name": "year",
            "documentation": "Extract the year part of the date as an Integer.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "month": {
            "name": "month",
            "documentation": "Extract the month part of the date as an Integer, or return 0 if not present.",
            "pre_conditions": {
                "Pre": "not month_unknown"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "day": {
            "name": "day",
            "documentation": "Extract the day part of the date as an Integer, or return 0 if not present.",
            "pre_conditions": {
                "Pre": "not day_unknown"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "timezone": {
            "name": "timezone",
            "documentation": "Timezone; may be Void.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_timezone"
            }
        },
        "month_unknown": {
            "name": "month_unknown",
            "documentation": "Indicates whether month in year is unknown. If so, the date is of the form `\"YYYY\"`.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "day_unknown": {
            "name": "day_unknown",
            "documentation": "Indicates whether day in month is unknown. If so, and month is known, the date is of the form `\"YYYY-MM\"` or `\"YYYYMM\"`.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_partial": {
            "name": "is_partial",
            "documentation": "True if this date is partial, i.e. if days or more is missing.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_extended": {
            "name": "is_extended",
            "documentation": "True if this date uses `'-'` separators.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "as_string": {
            "name": "as_string",
            "documentation": "Return string value in extended format.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "String"
            }
        },
        "add": {
            "name": "add",
            "aliases": [
                "+"
            ],
            "documentation": "Arithmetic addition of a duration to a date.",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_date"
            }
        },
        "subtract": {
            "name": "subtract",
            "aliases": [
                "-"
            ],
            "documentation": "Arithmetic subtraction of a duration from a date.",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_date"
            }
        },
        "diff": {
            "name": "diff",
            "aliases": [
                "-"
            ],
            "documentation": "Difference of two dates.",
            "parameters": {
                "a_date": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_date",
                    "type": "Iso8601_date"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_duration"
            }
        },
        "add_nominal": {
            "name": "add_nominal",
            "aliases": [
                "++"
            ],
            "documentation": "Addition of nominal duration represented by `_a_diff_`. For example, a duration of `'P1Y'` means advance to the same date next year, with the exception of the date 29 February in a leap year, to which the addition of a nominal year will result in 28 February of the following year. Similarly, `'P1M'` is understood here as a nominal month, the addition of which will result in one of:\n\n* the same day in the following month, if it exists, or;\n* one or two days less where the following month is shorter, or;\n* in the case of adding a month to the date 31 Jan, the result will be 28 Feb in a non-leap year (i.e. three less) and 29 Feb in a leap year (i.e. two less).",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_date"
            }
        },
        "subtract_nominal": {
            "name": "subtract_nominal",
            "aliases": [
                "--"
            ],
            "documentation": "Subtraction of nominal duration represented by `_a_diff_`. See `_add_nominal_()` for semantics.",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_date"
            }
        }
    },
    "invariants": {
        "Year_valid": "valid_year (year)",
        "Month_valid": "not month_unknown implies valid_month (month)",
        "Day_valid": "not day_unknown implies valid_day (year, month, day)",
        "Partial_validity": "month_unknown implies day_unknown"
    }
}
Iso8601_date

Iso8601_time Class

  • Definition

  • Effective

  • BMM

  • UML

Class

Iso8601_time

Description

Represents an ISO 8601 time, including partial and extended forms. Value may be:

  • hh:mm:ss[(,|.)sss][Z|±hh[:mm]] (extended, preferred) or

  • hhmmss[(,|.)sss][Z|±hh[mm]] (compact)

  • or a partial invariant.

See valid_iso8601_time() for validity.

A small deviation to the ISO 8601:2004 standard in this class is that the time 24:00:00 is not allowed, for consistency with Iso8601_date_time.

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1

hour (): Integer

Extract the hour part of the date/time as an Integer.

1..1

minute (): Integer

Extract the minute part of the time as an Integer, or return 0 if not present.

1..1

second (): Integer

Extract the integral seconds part of the time (i.e. prior to any decimal sign) as an Integer, or return 0 if not present.

1..1

fractional_second (): Real

Pre: not second_unknown

Extract the fractional seconds part of the time (i.e. following to any decimal sign) as a Real, or return 0.0 if not present.

1..1

timezone (): Iso8601_timezone

Timezone; may be Void.

1..1

minute_unknown (): Boolean

Indicates whether minute is unknown. If so, the time is of the form “hh”.

1..1

second_unknown (): Boolean

Indicates whether second is unknown. If so and month is known, the time is of the form "hh:mm" or "hhmm".

1..1

is_decimal_sign_comma (): Boolean

True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).

1..1
(effected)

is_partial (): Boolean

True if this time is partial, i.e. if seconds or more is missing.

1..1
(effected)

is_extended (): Boolean

True if this time uses '-', ':' separators.

1..1

has_fractional_second (): Boolean

True if the fractional_second part is significant (i.e. even if = 0.0).

1..1

as_string (): String

Return string value in extended format.

1..1

add alias "+" (
a_diff: Iso8601_duration[1]
): Iso8601_time

Arithmetic addition of a duration to a time.

1..1

subtract alias "-" (
a_diff: Iso8601_duration[1]
): Iso8601_time

Arithmetic subtraction of a duration from a time.

1..1

diff alias "-" (
a_time: Iso8601_time[1]
): Iso8601_duration

Difference of two times.

Invariants

Hour_valid: valid_hour(hour, minute, second)

Minute_valid: not minute_unknown implies valid_minute (minute)

Second_valid: not second_unknown implies valid_second (second)

Fractional_second_valid: has_fractional_second implies (not second_unknown and valid_fractional_second (fractional_second))

Partial_validity: minute_unknown implies second_unknown

Iso8601_time

Represents an ISO 8601 time, including partial and extended forms. Value may be:

  • hh:mm:ss[(,|.)sss][Z|±hh[:mm]] (extended, preferred) or

  • hhmmss[(,|.)sss][Z|±hh[mm]] (compact)

  • or a partial invariant.

See valid_iso8601_time() for validity.

A small deviation to the ISO 8601:2004 standard in this class is that the time 24:00:00 is not allowed, for consistency with Iso8601_date_time.

Inherits: Any, Ordered, Temporal, Time_Definitions, Iso8601_type

Constants

Time_Definitions.Seconds_in_minute: Integer = 60 [1..1]

Number of seconds in a minute.

Time_Definitions.Minutes_in_hour: Integer = 60 [1..1]

Number of minutes in an hour.

Time_Definitions.Hours_in_day: Integer = 24 [1..1]

Number of clock hours in a day, i.e. 24.

Time_Definitions.Average_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Max_days_in_month: Integer = 31 [1..1]

Maximum number of days in any month.

Time_Definitions.Days_in_year: Integer = 365 [1..1]

Calendar days in a normal year, i.e. 365.

Time_Definitions.Average_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Time_Definitions.Days_in_leap_year: Integer = 366 [1..1]

Calendar days in a standard leap year, i.e. 366.

Time_Definitions.Max_days_in_year: Integer = Days_in_leap_year [1..1]

Maximum number of days in a year, i.e. accounting for leap years.

Time_Definitions.Days_in_week: Integer = 7 [1..1]

Number of days in a week.

Time_Definitions.Months_in_year: Integer = 12 [1..1]

Number of months in a year.

Time_Definitions.Min_timezone_hour: Integer = 12 [1..1]

Minimum hour value of a timezone according to ISO 8601 (note that the -ve sign is supplied in the ISO8601_TIMEZONE class).

Time_Definitions.Max_timezone_hour: Integer = 14 [1..1]

Maximum hour value of a timezone according to ISO 8601.

Time_Definitions.Nominal_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Nominal_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Attributes

Iso8601_type.value: String [1..1]

Representation of all descendants is a single String.

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

Any.equal alias "=", "==" (
other: Any[1]
): Boolean [1..1]

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

Type name of an object as a string. May include generic parameters, as in "Interval<Time>".

Any.not_equal alias "!=", "≠" (
other: Ordered[1]
): Boolean [1..1]

True if current object not equal to other. Returns not equal().

(abstract) Ordered.less_than alias "<" (
other: Ordered[1]
): Boolean [1..1]

Arithmetic value comparison. Returns True if current object is less than other. This operator is effected and/or redefined in descendants to provide the appropriate ordering semantics for concrete types.

In conjunction with =, enables the definition of the related functions greater_than() etc.

Ordered.less_than_or_equal alias "⇐", "≤" (
other: Ordered[1]
): Boolean

Post_result: not (other < self) [1..1]

True if current object less than or equal to other.

Ordered.greater_than alias ">" (
other: Ordered[1]
): Boolean

Post_result: Result = (other < self) [1..1]

True if current object greater than other.

Ordered.greater_than_or_equal alias ">=", "≥" (
other: Ordered[1]
): Boolean

Post_result: Result = (other <= self) [1..1]

True if current object greater than or equal to other.

Time_Definitions.valid_year (
y: Integer[1]
): Boolean

Post: Result = y >= 0 [1..1]

True if y >= 0.

Time_Definitions.valid_month (
m: Integer[1]
): Boolean

Post: Result = m >= 1 and m <= Months_in_year [1..1]

True if m >= 1 and m <= months_in_year.

Time_Definitions.valid_day (
y: Integer[1],
m: Integer[1],
d: Integer[1]
): Boolean

Post: Result = d >= 1 and d <= days_in_month (m, y) [1..1]

True if d >= 1 and d <= days_in_month (m, y).

Time_Definitions.valid_hour (
h: Integer[1],
m: Integer[1],
s: Integer[1]
): Boolean

Post: Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) [1..1]

True if (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) .

Time_Definitions.valid_minute (
m: Integer[1]
): Boolean

Post: Result = m >= 0 and m < Minutes_in_hour [1..1]

True if m >= 0 and m < Minutes_in_hour.

Time_Definitions.valid_second (
s: Integer[1]
): Boolean

Post: Result = s >= 0 and s < Seconds_in_minute [1..1]

True if s >= 0 and s < Seconds_in_minute .

Time_Definitions.valid_fractional_second (
fs: Double[1]
): Boolean

Post: Result = fs >= 0.0 and fs < 1.0 [1..1]

True if fs >= 0.0 and fs < 1.0 .

Time_Definitions.valid_iso8601_date (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the complete form:

  • YYYY-MM-DD (extended, preferred) or one of the partial forms YYYY-MM or YYYY

  • YYYYMMDD (compact) or a partial variant YYYYMM.

Where:

  • YYYY is the string form of any positive number in the range 0000 - 9999 (zero-filled to four digits)

  • MM is 01 - 12 (zero-filled to two digits)

  • DD is 01 - 31 (zero-filled to two digits)

The combinations of YYYY, MM, DD numbers must be correct with respect to the Gregorian calendar.

Time_Definitions.valid_iso8601_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the form:

  • hh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • hhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • hh:mm (extended)

    • hhmm or hh (compact)

with an additional optional timezone indicator of:

  • Z or ±hh[:mm] (extended) ±hh[mm] (compact)

Where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • ss is "00" - "60" (0-filled to two digits)

  • [(,|.)s+] is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

Time_Definitions.valid_iso8601_date_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date-time, i.e. takes the form:

  • YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • YYYY-MM-DDThh:mm or YYYY-MM-DDThh (extended)

    • YYYYMMDDThhmm or YYYYMMDDThh (compact)

Time_Definitions.valid_iso8601_duration (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7-day weeks.

Note: allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

Parameters
s

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7- day weeks.

allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

is_partial (): Boolean [1..1]

True if this time is partial, i.e. if seconds or more is missing.

is_extended (): Boolean [1..1]

True if this time uses '-', ':' separators.

hour (): Integer [1..1]

Extract the hour part of the date/time as an Integer.

minute (): Integer [1..1]

Extract the minute part of the time as an Integer, or return 0 if not present.

second (): Integer [1..1]

Extract the integral seconds part of the time (i.e. prior to any decimal sign) as an Integer, or return 0 if not present.

fractional_second (): Real

Pre: not second_unknown [1..1]

Extract the fractional seconds part of the time (i.e. following to any decimal sign) as a Real, or return 0.0 if not present.

timezone (): Iso8601_timezone [1..1]

Timezone; may be Void.

minute_unknown (): Boolean [1..1]

Indicates whether minute is unknown. If so, the time is of the form “hh”.

second_unknown (): Boolean [1..1]

Indicates whether second is unknown. If so and month is known, the time is of the form "hh:mm" or "hhmm".

is_decimal_sign_comma (): Boolean [1..1]

True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).

has_fractional_second (): Boolean [1..1]

True if the fractional_second part is significant (i.e. even if = 0.0).

as_string (): String [1..1]

Return string value in extended format.

add alias "+" (
a_diff: Iso8601_duration[1]
): Iso8601_time [1..1]

Arithmetic addition of a duration to a time.

subtract alias "-" (
a_diff: Iso8601_duration[1]
): Iso8601_time [1..1]

Arithmetic subtraction of a duration from a time.

diff alias "-" (
a_time: Iso8601_time[1]
): Iso8601_duration [1..1]

Difference of two times.

Invariants

Hour_valid: valid_hour(hour, minute, second)

Minute_valid: not minute_unknown implies valid_minute (minute)

Second_valid: not second_unknown implies valid_second (second)

Fractional_second_valid: has_fractional_second implies (not second_unknown and valid_fractional_second (fractional_second))

Partial_validity: minute_unknown implies second_unknown

{
    "name": "Iso8601_time",
    "documentation": "Represents an ISO 8601 time, including partial and extended forms. Value may be:\n\n* `hh:mm:ss[(,|.)sss][Z|±hh[:mm]]` (extended, preferred) or\n* `hhmmss[(,|.)sss][Z|±hh[mm]]` (compact)\n* or a partial invariant.\n\nSee `_valid_iso8601_time()_` for validity.\n\nNOTE: A small deviation to the ISO 8601:2004 standard in this class is that the time `24:00:00` is not allowed, for consistency with `Iso8601_date_time`.",
    "ancestors": [
        "Iso8601_type"
    ],
    "functions": {
        "hour": {
            "name": "hour",
            "documentation": "Extract the hour part of the date/time as an Integer.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "minute": {
            "name": "minute",
            "documentation": "Extract the minute part of the time as an Integer, or return 0 if not present.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "second": {
            "name": "second",
            "documentation": "Extract the integral seconds part of the time (i.e. prior to any decimal sign) as an Integer, or return 0 if not present.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "fractional_second": {
            "name": "fractional_second",
            "documentation": "Extract the fractional seconds part of the time (i.e. following to any decimal sign) as a Real, or return 0.0 if not present.",
            "pre_conditions": {
                "Pre": "not second_unknown"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Real"
            }
        },
        "timezone": {
            "name": "timezone",
            "documentation": "Timezone; may be Void.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_timezone"
            }
        },
        "minute_unknown": {
            "name": "minute_unknown",
            "documentation": "Indicates whether minute is unknown. If so, the time is of the form “hh”.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "second_unknown": {
            "name": "second_unknown",
            "documentation": "Indicates whether second is unknown. If so and month is known, the time is of the form `\"hh:mm\"` or `\"hhmm\"`.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_decimal_sign_comma": {
            "name": "is_decimal_sign_comma",
            "documentation": "True if this time has a decimal part indicated by `','` (comma) rather than `'.'` (period).",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_partial": {
            "name": "is_partial",
            "documentation": "True if this time is partial, i.e. if seconds or more is missing.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_extended": {
            "name": "is_extended",
            "documentation": "True if this time uses `'-'`, `':'` separators.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "has_fractional_second": {
            "name": "has_fractional_second",
            "documentation": "True if the `_fractional_second_` part is significant (i.e. even if = 0.0).",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "as_string": {
            "name": "as_string",
            "documentation": "Return string value in extended format.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "String"
            }
        },
        "add": {
            "name": "add",
            "aliases": [
                "+"
            ],
            "documentation": "Arithmetic addition of a duration to a time.",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_time"
            }
        },
        "subtract": {
            "name": "subtract",
            "aliases": [
                "-"
            ],
            "documentation": "Arithmetic subtraction of a duration from a time.",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_time"
            }
        },
        "diff": {
            "name": "diff",
            "aliases": [
                "-"
            ],
            "documentation": "Difference of two times.",
            "parameters": {
                "a_time": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_time",
                    "type": "Iso8601_time"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_duration"
            }
        }
    },
    "invariants": {
        "Hour_valid": "valid_hour(hour, minute, second)",
        "Minute_valid": "not minute_unknown implies valid_minute (minute)",
        "Second_valid": "not second_unknown implies valid_second (second)",
        "Fractional_second_valid": "has_fractional_second implies (not second_unknown and valid_fractional_second (fractional_second))",
        "Partial_validity": "minute_unknown implies second_unknown"
    }
}
Iso8601_time

Iso8601_date_time Class

  • Definition

  • Effective

  • BMM

  • UML

Class

Iso8601_date_time

Description

Represents an ISO 8601 date/time, including partial and extended forms. Value may be:

  • YYYY-MM-DDThh:mm:ss[(,|.)sss][Z | ±hh[:mm]] (extended, preferred) or

  • YYYYMMDDThhmmss[(,|.)sss][Z | ±hh[mm]] (compact)

  • or a partial variant.

See valid_iso8601_date_time() for validity.

Note that this class includes 2 deviations from ISO 8601:2004:

  • for partial date/times, any part of the date/time up to the month may be missing, not just seconds and minutes as in the standard;

  • the time 24:00:00 is not allowed, since it would mean the date was really on the next day.

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1

year (): Integer

Extract the year part of the date as an Integer.

1..1

month (): Integer

Pre: not month_unknown

Extract the month part of the date/time as an Integer, or return 0 if not present.

1..1

day (): Integer

Pre: not day_unknown

Extract the day part of the date/time as an Integer, or return 0 if not present.

1..1

hour (): Integer

Pre: not hour_unknown

Extract the hour part of the date/time as an Integer, or return 0 if not present.

1..1

minute (): Integer

Pre: not minute_unknown

Extract the minute part of the date/time as an Integer, or return 0 if not present.

1..1

second (): Integer

Pre: not second_unknown

Extract the integral seconds part of the date/time (i.e. prior to any decimal sign) as an Integer, or return 0 if not present.

1..1

fractional_second (): Real

Extract the fractional seconds part of the date/time (i.e. following to any decimal sign) as a Real, or return 0.0 if not present.

1..1

timezone (): Iso8601_timezone

Timezone; may be Void.

1..1

month_unknown (): Boolean

Indicates whether month in year is unknown.

1..1

day_unknown (): Boolean

Indicates whether day in month is unknown.

1..1

minute_unknown (): Boolean

Indicates whether minute in hour is known.

1..1

second_unknown (): Boolean

Indicates whether minute in hour is known.

1..1

is_decimal_sign_comma (): Boolean

True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).

1..1
(effected)

is_partial (): Boolean

True if this date time is partial, i.e. if seconds or more is missing.

1..1
(effected)

is_extended (): Boolean

True if this date/time uses '-', ':' separators.

1..1

has_fractional_second (): Boolean

True if the fractional_second part is significant (i.e. even if = 0.0).

1..1

as_string (): String

Return the string value in extended format.

1..1

add alias "+" (
a_diff: Iso8601_duration[1]
): Iso8601_date_time

Arithmetic addition of a duration to a date/time.

1..1

subtract alias "-" (
a_diff: Iso8601_duration[1]
): Iso8601_date_time

Arithmetic subtraction of a duration from a date/time.

1..1

diff alias "-" (
a_date_time: Iso8601_date_time[1]
): Iso8601_duration

Difference of two date/times.

1..1

add_nominal alias "++" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Addition of nominal duration represented by a_diff. See Iso8601_date.add_nominal() for semantics.

1..1

subtract_nominal alias "--" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Subtraction of nominal duration represented by a_diff. See add_nominal() for semantics.

Invariants

Year_valid: valid_year (year)

Month_valid: valid_month (month)

Day_valid: valid_day(year, month, day)

Hour_valid: valid_hour (hour, minute, second)

Minute_valid: not minute_unknown implies valid_minute(minute)

Second_valid: not second_unknown implies valid_second (second)

Fractional_second_valid: has_fractional_second implies (not second_unknown and valid_fractional_second (fractional_second))

Partial_validity_year: not month_unknown

Partial_validity_month: not month_unknown

Partial_validity_day: not day_unknown

Partial_validity_hour: not hour_unknown

Partial_validity_minute: minute_unknown implies second_unknown

Iso8601_date_time

Represents an ISO 8601 date/time, including partial and extended forms. Value may be:

  • YYYY-MM-DDThh:mm:ss[(,|.)sss][Z | ±hh[:mm]] (extended, preferred) or

  • YYYYMMDDThhmmss[(,|.)sss][Z | ±hh[mm]] (compact)

  • or a partial variant.

See valid_iso8601_date_time() for validity.

Note that this class includes 2 deviations from ISO 8601:2004:

  • for partial date/times, any part of the date/time up to the month may be missing, not just seconds and minutes as in the standard;

  • the time 24:00:00 is not allowed, since it would mean the date was really on the next day.

Inherits: Any, Ordered, Temporal, Time_Definitions, Iso8601_type

Constants

Time_Definitions.Seconds_in_minute: Integer = 60 [1..1]

Number of seconds in a minute.

Time_Definitions.Minutes_in_hour: Integer = 60 [1..1]

Number of minutes in an hour.

Time_Definitions.Hours_in_day: Integer = 24 [1..1]

Number of clock hours in a day, i.e. 24.

Time_Definitions.Average_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Max_days_in_month: Integer = 31 [1..1]

Maximum number of days in any month.

Time_Definitions.Days_in_year: Integer = 365 [1..1]

Calendar days in a normal year, i.e. 365.

Time_Definitions.Average_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Time_Definitions.Days_in_leap_year: Integer = 366 [1..1]

Calendar days in a standard leap year, i.e. 366.

Time_Definitions.Max_days_in_year: Integer = Days_in_leap_year [1..1]

Maximum number of days in a year, i.e. accounting for leap years.

Time_Definitions.Days_in_week: Integer = 7 [1..1]

Number of days in a week.

Time_Definitions.Months_in_year: Integer = 12 [1..1]

Number of months in a year.

Time_Definitions.Min_timezone_hour: Integer = 12 [1..1]

Minimum hour value of a timezone according to ISO 8601 (note that the -ve sign is supplied in the ISO8601_TIMEZONE class).

Time_Definitions.Max_timezone_hour: Integer = 14 [1..1]

Maximum hour value of a timezone according to ISO 8601.

Time_Definitions.Nominal_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Nominal_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Attributes

Iso8601_type.value: String [1..1]

Representation of all descendants is a single String.

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

Any.equal alias "=", "==" (
other: Any[1]
): Boolean [1..1]

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

Type name of an object as a string. May include generic parameters, as in "Interval<Time>".

Any.not_equal alias "!=", "≠" (
other: Ordered[1]
): Boolean [1..1]

True if current object not equal to other. Returns not equal().

(abstract) Ordered.less_than alias "<" (
other: Ordered[1]
): Boolean [1..1]

Arithmetic value comparison. Returns True if current object is less than other. This operator is effected and/or redefined in descendants to provide the appropriate ordering semantics for concrete types.

In conjunction with =, enables the definition of the related functions greater_than() etc.

Ordered.less_than_or_equal alias "⇐", "≤" (
other: Ordered[1]
): Boolean

Post_result: not (other < self) [1..1]

True if current object less than or equal to other.

Ordered.greater_than alias ">" (
other: Ordered[1]
): Boolean

Post_result: Result = (other < self) [1..1]

True if current object greater than other.

Ordered.greater_than_or_equal alias ">=", "≥" (
other: Ordered[1]
): Boolean

Post_result: Result = (other <= self) [1..1]

True if current object greater than or equal to other.

Time_Definitions.valid_year (
y: Integer[1]
): Boolean

Post: Result = y >= 0 [1..1]

True if y >= 0.

Time_Definitions.valid_month (
m: Integer[1]
): Boolean

Post: Result = m >= 1 and m <= Months_in_year [1..1]

True if m >= 1 and m <= months_in_year.

Time_Definitions.valid_day (
y: Integer[1],
m: Integer[1],
d: Integer[1]
): Boolean

Post: Result = d >= 1 and d <= days_in_month (m, y) [1..1]

True if d >= 1 and d <= days_in_month (m, y).

Time_Definitions.valid_hour (
h: Integer[1],
m: Integer[1],
s: Integer[1]
): Boolean

Post: Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) [1..1]

True if (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) .

Time_Definitions.valid_minute (
m: Integer[1]
): Boolean

Post: Result = m >= 0 and m < Minutes_in_hour [1..1]

True if m >= 0 and m < Minutes_in_hour.

Time_Definitions.valid_second (
s: Integer[1]
): Boolean

Post: Result = s >= 0 and s < Seconds_in_minute [1..1]

True if s >= 0 and s < Seconds_in_minute .

Time_Definitions.valid_fractional_second (
fs: Double[1]
): Boolean

Post: Result = fs >= 0.0 and fs < 1.0 [1..1]

True if fs >= 0.0 and fs < 1.0 .

Time_Definitions.valid_iso8601_date (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the complete form:

  • YYYY-MM-DD (extended, preferred) or one of the partial forms YYYY-MM or YYYY

  • YYYYMMDD (compact) or a partial variant YYYYMM.

Where:

  • YYYY is the string form of any positive number in the range 0000 - 9999 (zero-filled to four digits)

  • MM is 01 - 12 (zero-filled to two digits)

  • DD is 01 - 31 (zero-filled to two digits)

The combinations of YYYY, MM, DD numbers must be correct with respect to the Gregorian calendar.

Time_Definitions.valid_iso8601_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the form:

  • hh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • hhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • hh:mm (extended)

    • hhmm or hh (compact)

with an additional optional timezone indicator of:

  • Z or ±hh[:mm] (extended) ±hh[mm] (compact)

Where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • ss is "00" - "60" (0-filled to two digits)

  • [(,|.)s+] is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

Time_Definitions.valid_iso8601_date_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date-time, i.e. takes the form:

  • YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • YYYY-MM-DDThh:mm or YYYY-MM-DDThh (extended)

    • YYYYMMDDThhmm or YYYYMMDDThh (compact)

Time_Definitions.valid_iso8601_duration (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7-day weeks.

Note: allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

Parameters
s

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7- day weeks.

allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

is_partial (): Boolean [1..1]

True if this date time is partial, i.e. if seconds or more is missing.

is_extended (): Boolean [1..1]

True if this date/time uses '-', ':' separators.

year (): Integer [1..1]

Extract the year part of the date as an Integer.

month (): Integer

Pre: not month_unknown [1..1]

Extract the month part of the date/time as an Integer, or return 0 if not present.

day (): Integer

Pre: not day_unknown [1..1]

Extract the day part of the date/time as an Integer, or return 0 if not present.

hour (): Integer

Pre: not hour_unknown [1..1]

Extract the hour part of the date/time as an Integer, or return 0 if not present.

minute (): Integer

Pre: not minute_unknown [1..1]

Extract the minute part of the date/time as an Integer, or return 0 if not present.

second (): Integer

Pre: not second_unknown [1..1]

Extract the integral seconds part of the date/time (i.e. prior to any decimal sign) as an Integer, or return 0 if not present.

fractional_second (): Real [1..1]

Extract the fractional seconds part of the date/time (i.e. following to any decimal sign) as a Real, or return 0.0 if not present.

timezone (): Iso8601_timezone [1..1]

Timezone; may be Void.

month_unknown (): Boolean [1..1]

Indicates whether month in year is unknown.

day_unknown (): Boolean [1..1]

Indicates whether day in month is unknown.

minute_unknown (): Boolean [1..1]

Indicates whether minute in hour is known.

second_unknown (): Boolean [1..1]

Indicates whether minute in hour is known.

is_decimal_sign_comma (): Boolean [1..1]

True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).

has_fractional_second (): Boolean [1..1]

True if the fractional_second part is significant (i.e. even if = 0.0).

as_string (): String [1..1]

Return the string value in extended format.

add alias "+" (
a_diff: Iso8601_duration[1]
): Iso8601_date_time [1..1]

Arithmetic addition of a duration to a date/time.

subtract alias "-" (
a_diff: Iso8601_duration[1]
): Iso8601_date_time [1..1]

Arithmetic subtraction of a duration from a date/time.

diff alias "-" (
a_date_time: Iso8601_date_time[1]
): Iso8601_duration [1..1]

Difference of two date/times.

add_nominal alias "++" (
a_diff: Iso8601_duration[1]
): Iso8601_date [1..1]

Addition of nominal duration represented by a_diff. See Iso8601_date.add_nominal() for semantics.

subtract_nominal alias "--" (
a_diff: Iso8601_duration[1]
): Iso8601_date [1..1]

Subtraction of nominal duration represented by a_diff. See add_nominal() for semantics.

Invariants

Year_valid: valid_year (year)

Month_valid: valid_month (month)

Day_valid: valid_day(year, month, day)

Hour_valid: valid_hour (hour, minute, second)

Minute_valid: not minute_unknown implies valid_minute(minute)

Second_valid: not second_unknown implies valid_second (second)

Fractional_second_valid: has_fractional_second implies (not second_unknown and valid_fractional_second (fractional_second))

Partial_validity_year: not month_unknown

Partial_validity_month: not month_unknown

Partial_validity_day: not day_unknown

Partial_validity_hour: not hour_unknown

Partial_validity_minute: minute_unknown implies second_unknown

{
    "name": "Iso8601_date_time",
    "documentation": "Represents an ISO 8601 date/time, including partial and extended forms. Value may be:\n\n* `YYYY-MM-DDThh:mm:ss[(,|.)sss][Z | ±hh[:mm]]` (extended, preferred) or\n* `YYYYMMDDThhmmss[(,|.)sss][Z | ±hh[mm]]` (compact)\n* or a partial variant.\n\nSee `_valid_iso8601_date_time()_` for validity.\n\nNote that this class includes 2 deviations from ISO 8601:2004:\n\n* for partial date/times, any part of the date/time up to the month may be missing, not just seconds and minutes as in the standard;\n* the time `24:00:00` is not allowed, since it would mean the date was really on the next day.",
    "ancestors": [
        "Iso8601_type"
    ],
    "functions": {
        "year": {
            "name": "year",
            "documentation": "Extract the year part of the date as an Integer.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "month": {
            "name": "month",
            "documentation": "Extract the month part of the date/time as an Integer, or return 0 if not present.",
            "pre_conditions": {
                "Pre": "not month_unknown"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "day": {
            "name": "day",
            "documentation": "Extract the day part of the date/time as an Integer, or return 0 if not present.",
            "pre_conditions": {
                "Pre": "not day_unknown"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "hour": {
            "name": "hour",
            "documentation": "Extract the hour part of the date/time as an Integer, or return 0 if not present.",
            "pre_conditions": {
                "Pre": "not hour_unknown"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "minute": {
            "name": "minute",
            "documentation": "Extract the minute part of the date/time as an Integer, or return 0 if not present.",
            "pre_conditions": {
                "Pre": "not minute_unknown"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "second": {
            "name": "second",
            "documentation": "Extract the integral seconds part of the date/time (i.e. prior to any decimal sign) as an Integer, or return 0 if not present.",
            "pre_conditions": {
                "Pre": "not second_unknown"
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "fractional_second": {
            "name": "fractional_second",
            "documentation": "Extract the fractional seconds part of the date/time (i.e. following to any decimal sign) as a Real, or return 0.0 if not present.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Real"
            }
        },
        "timezone": {
            "name": "timezone",
            "documentation": "Timezone; may be Void.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_timezone"
            }
        },
        "month_unknown": {
            "name": "month_unknown",
            "documentation": "Indicates whether month in year is unknown.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "day_unknown": {
            "name": "day_unknown",
            "documentation": "Indicates whether day in month is unknown.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "minute_unknown": {
            "name": "minute_unknown",
            "documentation": "Indicates whether minute in hour is known.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "second_unknown": {
            "name": "second_unknown",
            "documentation": "Indicates whether minute in hour is known.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_decimal_sign_comma": {
            "name": "is_decimal_sign_comma",
            "documentation": "True if this time has a decimal part indicated by `','` (comma) rather than `'.'` (period).",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_partial": {
            "name": "is_partial",
            "documentation": "True if this date time is partial, i.e. if seconds or more is missing.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_extended": {
            "name": "is_extended",
            "documentation": "True if this date/time uses `'-'`, `':'` separators.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "has_fractional_second": {
            "name": "has_fractional_second",
            "documentation": "True if the `_fractional_second_` part is significant (i.e. even if = 0.0).",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "as_string": {
            "name": "as_string",
            "documentation": "Return the string value in extended format.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "String"
            }
        },
        "add": {
            "name": "add",
            "aliases": [
                "+"
            ],
            "documentation": "Arithmetic addition of a duration to a date/time.",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_date_time"
            }
        },
        "subtract": {
            "name": "subtract",
            "aliases": [
                "-"
            ],
            "documentation": "Arithmetic subtraction of a duration from a date/time.",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_date_time"
            }
        },
        "diff": {
            "name": "diff",
            "aliases": [
                "-"
            ],
            "documentation": "Difference of two date/times.",
            "parameters": {
                "a_date_time": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_date_time",
                    "type": "Iso8601_date_time"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_duration"
            }
        },
        "add_nominal": {
            "name": "add_nominal",
            "aliases": [
                "++"
            ],
            "documentation": "Addition of nominal duration represented by `_a_diff_`. See `Iso8601_date._add_nominal_()` for semantics.",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_date"
            }
        },
        "subtract_nominal": {
            "name": "subtract_nominal",
            "aliases": [
                "--"
            ],
            "documentation": "Subtraction of nominal duration represented by `_a_diff_`. See `_add_nominal_()` for semantics.",
            "parameters": {
                "a_diff": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_diff",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_date"
            }
        }
    },
    "invariants": {
        "Year_valid": "valid_year (year)",
        "Month_valid": "valid_month (month)",
        "Day_valid": "valid_day(year, month, day)",
        "Hour_valid": "valid_hour (hour, minute, second)",
        "Minute_valid": "not minute_unknown implies valid_minute(minute)",
        "Second_valid": "not second_unknown implies valid_second (second)",
        "Fractional_second_valid": "has_fractional_second implies (not second_unknown and valid_fractional_second (fractional_second))",
        "Partial_validity_year": "not month_unknown",
        "Partial_validity_month": "not month_unknown",
        "Partial_validity_day": "not day_unknown",
        "Partial_validity_hour": "not hour_unknown",
        "Partial_validity_minute": "minute_unknown implies second_unknown"
    }
}
Iso8601_date_time

Iso8601_duration Class

  • Definition

  • Effective

  • BMM

  • UML

Class

Iso8601_duration

Description

Represents an ISO 8601 duration, which may have multiple parts from years down to seconds. The value attribute is a String in the format:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

two deviations from ISO 8601 are supported, the first, to allow a negative sign, and the second allowing the 'W' designator to be mixed with other designators.

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1
(effected)

is_extended (): Boolean

Returns True.

1..1
(effected)

is_partial (): Boolean

Returns False.

1..1

years (): Integer

Number of years in the value, i.e. the number preceding the 'Y' in the 'YMD' part, if one exists.

1..1

months (): Integer

Number of months in the value, i.e. the value preceding the 'M' in the 'YMD' part, if one exists.

1..1

days (): Integer

Number of days in the value, i.e. the number preceding the 'D' in the 'YMD' part, if one exists.

1..1

hours (): Integer

Number of hours in the value, i.e. the number preceding the 'H' in the 'HMS' part, if one exists.

1..1

minutes (): Integer

Number of minutes in the value, i.e. the number preceding the 'M' in the 'HMS' part, if one exists.

1..1

seconds (): Integer

Number of seconds in the value, i.e. the integer number preceding the 'S' in the 'HMS' part, if one exists.

1..1

fractional_seconds (): Real

Fractional seconds in the value, i.e. the decimal part of the number preceding the 'S' in the 'HMS' part, if one exists.

1..1

weeks (): Integer

Number of weeks in the value, i.e. the value preceding the W, if one exists.

1..1

is_decimal_sign_comma (): Boolean

True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).

1..1

to_seconds (): Real

Total number of seconds equivalent (including fractional) of entire duration. Where non-definite elements such as year and month (i.e. 'Y' and 'M') are included, the corresponding 'average' durations from Time_definitions are used to compute the result.

1..1

as_string (): String

Return the duration string value.

1..1

add alias "+" (
a_val: Iso8601_duration[1]
): Iso8601_duration

Arithmetic addition of a duration to a duration, via conversion to seconds, using Time_definitions.Average_days_in_year and Time_definitions.Average_days_in_month

1..1

subtract alias "-" (
a_val: Iso8601_duration[1]
): Iso8601_duration

Arithmetic subtraction of a duration from a duration, via conversion to seconds, using Time_definitions.Average_days_in_year and Time_definitions.Average_days_in_month

1..1

multiply alias "*" (
a_val: Real[1]
): Iso8601_duration

Arithmetic multiplication a duration by a number.

1..1

divide alias "/" (
a_val: Real[1]
): Iso8601_duration

Arithmetic division of a duration by a number.

1..1

negative alias "-" (): Iso8601_duration

Generate negative of current duration value.

Invariants

Years_valid: years >= 0

Months_valid: months >= 0

Weeks_valid: weeks >= 0

Days_valid: days >= 0

Hours_valid: hours >= 0

Minutes_valid: minutes >= 0

Seconds_valid: seconds >= 0

Fractional_second_valid: fractional_second >= 0.0 and fractional_second < 1.0

Iso8601_duration

Represents an ISO 8601 duration, which may have multiple parts from years down to seconds. The value attribute is a String in the format:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

two deviations from ISO 8601 are supported, the first, to allow a negative sign, and the second allowing the 'W' designator to be mixed with other designators.

Inherits: Any, Ordered, Temporal, Time_Definitions, Iso8601_type

Constants

Time_Definitions.Seconds_in_minute: Integer = 60 [1..1]

Number of seconds in a minute.

Time_Definitions.Minutes_in_hour: Integer = 60 [1..1]

Number of minutes in an hour.

Time_Definitions.Hours_in_day: Integer = 24 [1..1]

Number of clock hours in a day, i.e. 24.

Time_Definitions.Average_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Max_days_in_month: Integer = 31 [1..1]

Maximum number of days in any month.

Time_Definitions.Days_in_year: Integer = 365 [1..1]

Calendar days in a normal year, i.e. 365.

Time_Definitions.Average_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Time_Definitions.Days_in_leap_year: Integer = 366 [1..1]

Calendar days in a standard leap year, i.e. 366.

Time_Definitions.Max_days_in_year: Integer = Days_in_leap_year [1..1]

Maximum number of days in a year, i.e. accounting for leap years.

Time_Definitions.Days_in_week: Integer = 7 [1..1]

Number of days in a week.

Time_Definitions.Months_in_year: Integer = 12 [1..1]

Number of months in a year.

Time_Definitions.Min_timezone_hour: Integer = 12 [1..1]

Minimum hour value of a timezone according to ISO 8601 (note that the -ve sign is supplied in the ISO8601_TIMEZONE class).

Time_Definitions.Max_timezone_hour: Integer = 14 [1..1]

Maximum hour value of a timezone according to ISO 8601.

Time_Definitions.Nominal_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Nominal_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Attributes

Iso8601_type.value: String [1..1]

Representation of all descendants is a single String.

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

Any.equal alias "=", "==" (
other: Any[1]
): Boolean [1..1]

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

Type name of an object as a string. May include generic parameters, as in "Interval<Time>".

Any.not_equal alias "!=", "≠" (
other: Ordered[1]
): Boolean [1..1]

True if current object not equal to other. Returns not equal().

(abstract) Ordered.less_than alias "<" (
other: Ordered[1]
): Boolean [1..1]

Arithmetic value comparison. Returns True if current object is less than other. This operator is effected and/or redefined in descendants to provide the appropriate ordering semantics for concrete types.

In conjunction with =, enables the definition of the related functions greater_than() etc.

Ordered.less_than_or_equal alias "⇐", "≤" (
other: Ordered[1]
): Boolean

Post_result: not (other < self) [1..1]

True if current object less than or equal to other.

Ordered.greater_than alias ">" (
other: Ordered[1]
): Boolean

Post_result: Result = (other < self) [1..1]

True if current object greater than other.

Ordered.greater_than_or_equal alias ">=", "≥" (
other: Ordered[1]
): Boolean

Post_result: Result = (other <= self) [1..1]

True if current object greater than or equal to other.

Time_Definitions.valid_year (
y: Integer[1]
): Boolean

Post: Result = y >= 0 [1..1]

True if y >= 0.

Time_Definitions.valid_month (
m: Integer[1]
): Boolean

Post: Result = m >= 1 and m <= Months_in_year [1..1]

True if m >= 1 and m <= months_in_year.

Time_Definitions.valid_day (
y: Integer[1],
m: Integer[1],
d: Integer[1]
): Boolean

Post: Result = d >= 1 and d <= days_in_month (m, y) [1..1]

True if d >= 1 and d <= days_in_month (m, y).

Time_Definitions.valid_hour (
h: Integer[1],
m: Integer[1],
s: Integer[1]
): Boolean

Post: Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) [1..1]

True if (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) .

Time_Definitions.valid_minute (
m: Integer[1]
): Boolean

Post: Result = m >= 0 and m < Minutes_in_hour [1..1]

True if m >= 0 and m < Minutes_in_hour.

Time_Definitions.valid_second (
s: Integer[1]
): Boolean

Post: Result = s >= 0 and s < Seconds_in_minute [1..1]

True if s >= 0 and s < Seconds_in_minute .

Time_Definitions.valid_fractional_second (
fs: Double[1]
): Boolean

Post: Result = fs >= 0.0 and fs < 1.0 [1..1]

True if fs >= 0.0 and fs < 1.0 .

Time_Definitions.valid_iso8601_date (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the complete form:

  • YYYY-MM-DD (extended, preferred) or one of the partial forms YYYY-MM or YYYY

  • YYYYMMDD (compact) or a partial variant YYYYMM.

Where:

  • YYYY is the string form of any positive number in the range 0000 - 9999 (zero-filled to four digits)

  • MM is 01 - 12 (zero-filled to two digits)

  • DD is 01 - 31 (zero-filled to two digits)

The combinations of YYYY, MM, DD numbers must be correct with respect to the Gregorian calendar.

Time_Definitions.valid_iso8601_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the form:

  • hh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • hhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • hh:mm (extended)

    • hhmm or hh (compact)

with an additional optional timezone indicator of:

  • Z or ±hh[:mm] (extended) ±hh[mm] (compact)

Where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • ss is "00" - "60" (0-filled to two digits)

  • [(,|.)s+] is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

Time_Definitions.valid_iso8601_date_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date-time, i.e. takes the form:

  • YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • YYYY-MM-DDThh:mm or YYYY-MM-DDThh (extended)

    • YYYYMMDDThhmm or YYYYMMDDThh (compact)

Time_Definitions.valid_iso8601_duration (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7-day weeks.

Note: allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

Parameters
s

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7- day weeks.

allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

is_partial (): Boolean [1..1]

Returns False.

is_extended (): Boolean [1..1]

Returns True.

years (): Integer [1..1]

Number of years in the value, i.e. the number preceding the 'Y' in the 'YMD' part, if one exists.

months (): Integer [1..1]

Number of months in the value, i.e. the value preceding the 'M' in the 'YMD' part, if one exists.

days (): Integer [1..1]

Number of days in the value, i.e. the number preceding the 'D' in the 'YMD' part, if one exists.

hours (): Integer [1..1]

Number of hours in the value, i.e. the number preceding the 'H' in the 'HMS' part, if one exists.

minutes (): Integer [1..1]

Number of minutes in the value, i.e. the number preceding the 'M' in the 'HMS' part, if one exists.

seconds (): Integer [1..1]

Number of seconds in the value, i.e. the integer number preceding the 'S' in the 'HMS' part, if one exists.

fractional_seconds (): Real [1..1]

Fractional seconds in the value, i.e. the decimal part of the number preceding the 'S' in the 'HMS' part, if one exists.

weeks (): Integer [1..1]

Number of weeks in the value, i.e. the value preceding the W, if one exists.

is_decimal_sign_comma (): Boolean [1..1]

True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).

to_seconds (): Real [1..1]

Total number of seconds equivalent (including fractional) of entire duration. Where non-definite elements such as year and month (i.e. 'Y' and 'M') are included, the corresponding 'average' durations from Time_definitions are used to compute the result.

as_string (): String [1..1]

Return the duration string value.

add alias "+" (
a_val: Iso8601_duration[1]
): Iso8601_duration [1..1]

Arithmetic addition of a duration to a duration, via conversion to seconds, using Time_definitions.Average_days_in_year and Time_definitions.Average_days_in_month

subtract alias "-" (
a_val: Iso8601_duration[1]
): Iso8601_duration [1..1]

Arithmetic subtraction of a duration from a duration, via conversion to seconds, using Time_definitions.Average_days_in_year and Time_definitions.Average_days_in_month

multiply alias "*" (
a_val: Real[1]
): Iso8601_duration [1..1]

Arithmetic multiplication a duration by a number.

divide alias "/" (
a_val: Real[1]
): Iso8601_duration [1..1]

Arithmetic division of a duration by a number.

negative alias "-" (): Iso8601_duration [1..1]

Generate negative of current duration value.

Invariants

Years_valid: years >= 0

Months_valid: months >= 0

Weeks_valid: weeks >= 0

Days_valid: days >= 0

Hours_valid: hours >= 0

Minutes_valid: minutes >= 0

Seconds_valid: seconds >= 0

Fractional_second_valid: fractional_second >= 0.0 and fractional_second < 1.0

{
    "name": "Iso8601_duration",
    "documentation": "Represents an ISO 8601 duration, which may have multiple parts from years down to seconds. The `_value_` attribute is a String in the format:\n\n* `P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]`\n\nNOTE: two deviations from ISO 8601 are supported, the first, to allow a negative sign, and the second allowing the 'W' designator to be mixed with other designators.",
    "ancestors": [
        "Iso8601_type"
    ],
    "functions": {
        "is_extended": {
            "name": "is_extended",
            "documentation": "Returns True.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_partial": {
            "name": "is_partial",
            "documentation": "Returns False.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "years": {
            "name": "years",
            "documentation": "Number of years in the `_value_`, i.e. the number preceding the `'Y'` in the `'YMD'` part, if one exists.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "months": {
            "name": "months",
            "documentation": "Number of months in the `_value_`, i.e. the value preceding the `'M'` in the `'YMD'` part, if one exists.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "days": {
            "name": "days",
            "documentation": "Number of days in the `_value_`, i.e. the number preceding the `'D'` in the `'YMD'` part, if one exists.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "hours": {
            "name": "hours",
            "documentation": "Number of hours in the `_value_`, i.e. the number preceding the `'H'` in the `'HMS'` part, if one exists.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "minutes": {
            "name": "minutes",
            "documentation": "Number of minutes in the `_value_`, i.e. the number preceding the `'M'` in the `'HMS'` part, if one exists.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "seconds": {
            "name": "seconds",
            "documentation": "Number of seconds in the `_value_`, i.e. the integer number preceding the `'S'` in the `'HMS'` part, if one exists.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "fractional_seconds": {
            "name": "fractional_seconds",
            "documentation": "Fractional seconds in the `_value_`, i.e. the decimal part of the number preceding the `'S'` in the `'HMS'` part, if one exists.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Real"
            }
        },
        "weeks": {
            "name": "weeks",
            "documentation": "Number of weeks in the `_value_`, i.e. the value preceding the `W`, if one exists.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "is_decimal_sign_comma": {
            "name": "is_decimal_sign_comma",
            "documentation": "True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "to_seconds": {
            "name": "to_seconds",
            "documentation": "Total number of seconds equivalent (including fractional) of entire duration. Where non-definite elements such as year and month (i.e. 'Y' and 'M') are included, the corresponding 'average' durations from `Time_definitions` are used to compute the result.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Real"
            }
        },
        "as_string": {
            "name": "as_string",
            "documentation": "Return the duration string value.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "String"
            }
        },
        "add": {
            "name": "add",
            "aliases": [
                "+"
            ],
            "documentation": "Arithmetic addition of a duration to a duration, via conversion to seconds, using `Time_definitions._Average_days_in_year_` and `Time_definitions._Average_days_in_month_`",
            "parameters": {
                "a_val": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_val",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_duration"
            }
        },
        "subtract": {
            "name": "subtract",
            "aliases": [
                "-"
            ],
            "documentation": "Arithmetic subtraction of a duration from a duration, via conversion to seconds, using `Time_definitions._Average_days_in_year_` and `Time_definitions._Average_days_in_month_`",
            "parameters": {
                "a_val": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_val",
                    "type": "Iso8601_duration"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_duration"
            }
        },
        "multiply": {
            "name": "multiply",
            "aliases": [
                "&#42;"
            ],
            "documentation": "Arithmetic multiplication a duration by a number.",
            "parameters": {
                "a_val": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_val",
                    "type": "Real"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_duration"
            }
        },
        "divide": {
            "name": "divide",
            "aliases": [
                "/"
            ],
            "documentation": "Arithmetic division of a duration by a number.",
            "parameters": {
                "a_val": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_val",
                    "type": "Real"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_duration"
            }
        },
        "negative": {
            "name": "negative",
            "aliases": [
                "-"
            ],
            "documentation": "Generate negative of current duration value.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Iso8601_duration"
            }
        }
    },
    "invariants": {
        "Years_valid": "years >= 0",
        "Months_valid": "months >= 0",
        "Weeks_valid": "weeks >= 0",
        "Days_valid": "days >= 0",
        "Hours_valid": "hours >= 0",
        "Minutes_valid": "minutes >= 0",
        "Seconds_valid": "seconds >= 0",
        "Fractional_second_valid": "fractional_second >= 0.0 and fractional_second < 1.0"
    }
}
Iso8601_duration

Iso8601_timezone Class

  • Definition

  • Effective

  • BMM

  • UML

Class

Iso8601_timezone

Description

ISO8601 timezone string, in format:

  • Z | ±hh[mm]

where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1

hour (): Integer

Extract the hour part of timezone, as an Integer in the range 00 - 14.

1..1

minute (): Integer

Extract the hour part of timezone, as an Integer, usually either 0 or 30.

1..1

sign (): Integer

Direction of timezone expresssed as +1 or -1.

1..1

minute_unknown (): Boolean

Indicates whether minute part known.

1..1
(effected)

is_partial (): Boolean

True if this time zone is partial, i.e. if minutes is missing.

1..1
(effected)

is_extended (): Boolean

True if this time-zone uses ‘:’ separators.

1..1

is_gmt (): Boolean

True if timezone is UTC, i.e. +0000.

1..1

as_string (): String

Return timezone string in extended format.

Invariants

Min_hour_valid: sign = -1 implies hour > 0 and hour <= Min_timezone_hour

Max_hour_valid: sign = 1 implies hour > 0 and hour <= Max_timezone_hour

Minute_valid: not minute_unknown implies valid_minute (minute)

Sign_valid: sign = 1 or sign = -1

Iso8601_timezone

ISO8601 timezone string, in format:

  • Z | ±hh[mm]

where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

Inherits: Any, Ordered, Temporal, Time_Definitions, Iso8601_type

Constants

Time_Definitions.Seconds_in_minute: Integer = 60 [1..1]

Number of seconds in a minute.

Time_Definitions.Minutes_in_hour: Integer = 60 [1..1]

Number of minutes in an hour.

Time_Definitions.Hours_in_day: Integer = 24 [1..1]

Number of clock hours in a day, i.e. 24.

Time_Definitions.Average_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Max_days_in_month: Integer = 31 [1..1]

Maximum number of days in any month.

Time_Definitions.Days_in_year: Integer = 365 [1..1]

Calendar days in a normal year, i.e. 365.

Time_Definitions.Average_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Time_Definitions.Days_in_leap_year: Integer = 366 [1..1]

Calendar days in a standard leap year, i.e. 366.

Time_Definitions.Max_days_in_year: Integer = Days_in_leap_year [1..1]

Maximum number of days in a year, i.e. accounting for leap years.

Time_Definitions.Days_in_week: Integer = 7 [1..1]

Number of days in a week.

Time_Definitions.Months_in_year: Integer = 12 [1..1]

Number of months in a year.

Time_Definitions.Min_timezone_hour: Integer = 12 [1..1]

Minimum hour value of a timezone according to ISO 8601 (note that the -ve sign is supplied in the ISO8601_TIMEZONE class).

Time_Definitions.Max_timezone_hour: Integer = 14 [1..1]

Maximum hour value of a timezone according to ISO 8601.

Time_Definitions.Nominal_days_in_month: Real = 30.42 [1..1]

Used for conversions of durations containing months to days and / or seconds.

Time_Definitions.Nominal_days_in_year: Real = 365.24 [1..1]

Used for conversions of durations containing years to days and / or seconds.

Attributes

Iso8601_type.value: String [1..1]

Representation of all descendants is a single String.

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

Any.equal alias "=", "==" (
other: Any[1]
): Boolean [1..1]

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

Type name of an object as a string. May include generic parameters, as in "Interval<Time>".

Any.not_equal alias "!=", "≠" (
other: Ordered[1]
): Boolean [1..1]

True if current object not equal to other. Returns not equal().

(abstract) Ordered.less_than alias "<" (
other: Ordered[1]
): Boolean [1..1]

Arithmetic value comparison. Returns True if current object is less than other. This operator is effected and/or redefined in descendants to provide the appropriate ordering semantics for concrete types.

In conjunction with =, enables the definition of the related functions greater_than() etc.

Ordered.less_than_or_equal alias "⇐", "≤" (
other: Ordered[1]
): Boolean

Post_result: not (other < self) [1..1]

True if current object less than or equal to other.

Ordered.greater_than alias ">" (
other: Ordered[1]
): Boolean

Post_result: Result = (other < self) [1..1]

True if current object greater than other.

Ordered.greater_than_or_equal alias ">=", "≥" (
other: Ordered[1]
): Boolean

Post_result: Result = (other <= self) [1..1]

True if current object greater than or equal to other.

Time_Definitions.valid_year (
y: Integer[1]
): Boolean

Post: Result = y >= 0 [1..1]

True if y >= 0.

Time_Definitions.valid_month (
m: Integer[1]
): Boolean

Post: Result = m >= 1 and m <= Months_in_year [1..1]

True if m >= 1 and m <= months_in_year.

Time_Definitions.valid_day (
y: Integer[1],
m: Integer[1],
d: Integer[1]
): Boolean

Post: Result = d >= 1 and d <= days_in_month (m, y) [1..1]

True if d >= 1 and d <= days_in_month (m, y).

Time_Definitions.valid_hour (
h: Integer[1],
m: Integer[1],
s: Integer[1]
): Boolean

Post: Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) [1..1]

True if (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) .

Time_Definitions.valid_minute (
m: Integer[1]
): Boolean

Post: Result = m >= 0 and m < Minutes_in_hour [1..1]

True if m >= 0 and m < Minutes_in_hour.

Time_Definitions.valid_second (
s: Integer[1]
): Boolean

Post: Result = s >= 0 and s < Seconds_in_minute [1..1]

True if s >= 0 and s < Seconds_in_minute .

Time_Definitions.valid_fractional_second (
fs: Double[1]
): Boolean

Post: Result = fs >= 0.0 and fs < 1.0 [1..1]

True if fs >= 0.0 and fs < 1.0 .

Time_Definitions.valid_iso8601_date (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the complete form:

  • YYYY-MM-DD (extended, preferred) or one of the partial forms YYYY-MM or YYYY

  • YYYYMMDD (compact) or a partial variant YYYYMM.

Where:

  • YYYY is the string form of any positive number in the range 0000 - 9999 (zero-filled to four digits)

  • MM is 01 - 12 (zero-filled to two digits)

  • DD is 01 - 31 (zero-filled to two digits)

The combinations of YYYY, MM, DD numbers must be correct with respect to the Gregorian calendar.

Time_Definitions.valid_iso8601_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date, i.e. takes the form:

  • hh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • hhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • hh:mm (extended)

    • hhmm or hh (compact)

with an additional optional timezone indicator of:

  • Z or ±hh[:mm] (extended) ±hh[mm] (compact)

Where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • ss is "00" - "60" (0-filled to two digits)

  • [(,|.)s+] is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

Time_Definitions.valid_iso8601_date_time (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 date-time, i.e. takes the form:

  • YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • YYYY-MM-DDThh:mm or YYYY-MM-DDThh (extended)

    • YYYYMMDDThhmm or YYYYMMDDThh (compact)

Time_Definitions.valid_iso8601_duration (
s: String[1]
): Boolean [1..1]

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7-day weeks.

Note: allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

Parameters
s

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7- day weeks.

allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

is_partial (): Boolean [1..1]

True if this time zone is partial, i.e. if minutes is missing.

is_extended (): Boolean [1..1]

True if this time-zone uses ‘:’ separators.

hour (): Integer [1..1]

Extract the hour part of timezone, as an Integer in the range 00 - 14.

minute (): Integer [1..1]

Extract the hour part of timezone, as an Integer, usually either 0 or 30.

sign (): Integer [1..1]

Direction of timezone expresssed as +1 or -1.

minute_unknown (): Boolean [1..1]

Indicates whether minute part known.

is_gmt (): Boolean [1..1]

True if timezone is UTC, i.e. +0000.

as_string (): String [1..1]

Return timezone string in extended format.

Invariants

Min_hour_valid: sign = -1 implies hour > 0 and hour <= Min_timezone_hour

Max_hour_valid: sign = 1 implies hour > 0 and hour <= Max_timezone_hour

Minute_valid: not minute_unknown implies valid_minute (minute)

Sign_valid: sign = 1 or sign = -1

{
    "name": "Iso8601_timezone",
    "documentation": "ISO8601 timezone string, in format:\n\n* `Z | ±hh[mm]`\n\nwhere:\n\n* `hh` is \"00\" - \"23\" (0-filled to two digits)\n* `mm` is \"00\" - \"59\" (0-filled to two digits)\n* `Z` is a literal meaning UTC (modern replacement for GMT), i.e. timezone `+0000`\n",
    "ancestors": [
        "Iso8601_type"
    ],
    "functions": {
        "hour": {
            "name": "hour",
            "documentation": "Extract the hour part of timezone, as an Integer in the range `00 - 14`.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "minute": {
            "name": "minute",
            "documentation": "Extract the hour part of timezone, as an Integer, usually either 0 or 30.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "sign": {
            "name": "sign",
            "documentation": "Direction of timezone expresssed as +1 or -1.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "minute_unknown": {
            "name": "minute_unknown",
            "documentation": "Indicates whether minute part known.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_partial": {
            "name": "is_partial",
            "documentation": "True if this time zone is partial, i.e. if minutes is missing.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_extended": {
            "name": "is_extended",
            "documentation": "True if this time-zone uses ‘:’ separators.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_gmt": {
            "name": "is_gmt",
            "documentation": "True if timezone is UTC, i.e. `+0000`.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "as_string": {
            "name": "as_string",
            "documentation": "Return timezone string in extended format.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "String"
            }
        }
    },
    "invariants": {
        "Min_hour_valid": "sign = -1 implies hour > 0 and hour <= Min_timezone_hour",
        "Max_hour_valid": "sign = 1 implies hour > 0 and hour <= Max_timezone_hour",
        "Minute_valid": "not minute_unknown implies valid_minute (minute)",
        "Sign_valid": "sign = 1 or sign = -1"
    }
}
Iso8601_timezone