Home Index classes Index static functions Index enumerations Index structure types

{Date_time|_manipulations}


CLASS {Date_time|_manipulations} , ABSTRACT, NATIVE, TESTED :


The special structure {date_time} is introduced in this abstract class to represent a time.


IMPORT : {NATIVE_Date_time} , {Mathematics} , {String_functions} .


--------------------- 'structure type for variables representing date/time'

  

STRUCTURE {date_time}

      REAL dt|_represents_date_and_time .


The structure type to store time.


FUNCTION DT|_inner_real_value_in_milliseconds (
     
{date_time} V|alue_struncture ) ==> REAL



FUNCTION Date_time|_from_milliseconds (
     
REAL DT|_milliseonds_from_0BC ) ==> {date_time}



ENUMERATION {day|_of_week} :

        'SUNDAY|_WEEK' ,

        'MONDAY|_WEEK' ,

        'TUESDAY|_WEEK' ,

        'WEDNESDAY|_WEEK' ,

        'THURSDAY|_WEEK' ,

        'FRIDAY|WEEK' ,

        'SATURDAY|_WEEK' .


The day of week.


-------------------------------------------------------- 'create date/time'


FUNCTION Date|_encode (
     
INT Year|_e_g_2019 ,
     
INT Month|_date_1_to_12 ,
     
INT Day|_of_month_1_to_31 ) ==> {date_time}


Creating an instance of date/time from values of year, month and day. The resulting instance has time set to 0:00.


FUNCTION Now|_date_time ==> {date_time}


Current date and time (local).


FUNCTION UTC_now|_date_and_time ==> {date_time}


Current date and time (universal).


---------------- 'add/subtract days, hours, minutes, seconds, milliseconds'


FUNCTION Add_months (
     
{date_time} DT|_source ,
     
INT M|onths_add_negative_to_subtract ) ==> {date_time}


Adding or subtracting months. Pass 12 to add a year.


FUNCTION Add_days (
     
{date_time} DT_source ,
     
REAL D|ays_add ) ==> {date_time}


Adding or subtracting days.


FUNCTION Add_hours (
     
{date_time} DT_source ,
     
INT Hours|_add ) ==> {date_time}


Adding or subtracting hours.


FUNCTION Add_minutes (
     
{date_time} DT_source ,
     
INT M|inutes_add ) ==> {date_time}


Adding or subtracting minutes.


FUNCTION Add_seconds (
     
{date_time} DT_source ,
     
INT S|econds_add ) ==> {date_time}


Adding or subtracting seconds.


FUNCTION Add_millisec|onds (
     
{date_time} DT_source ,
     
INT MS|econds_add ) ==> {date_time}


Adding or subtracting milliseconds.


FUNCTION Difference|_in_days (
     
{date_time} A|fter_date_time ,
     
{date_time} B|efore_date_time ) ==> REAL


Difference between two times measured in days (as a real number where the fractional part represents part of a day).


FUN Compare|_date (
     
{date_time} A|fter_date_time ,
     
{date_time} B|efore_date_time ) ==> REAL


Comparing two times subtracting them. Actually, reusult is a difference in milliseconds (and parts of milliseconds if available), which sign can be used to compare two dates.


FUN Hours_diff|erence (
     
{date_time} A|fter_date_time ,
     
{date_time} B|efore_date_time ) ==> REAL


Difference between two times measured in hours (as a real number where the fractional part represents part of a hour).


FUN Minutes_diff|erenceate_time (
     
{date_time} A|fter_date_time ,
     
{date_time} B|efore_date_time ) ==> REAL


Difference between two times measured in minutes (as a real number where the fractional part represents part of a minute).


FUN Seconds_diff|erenceate_time (
     
{date_time} A|fter_date_time ,
     
{date_time} B|efore_date_time ) ==> REAL


Difference between two times measured in seconds (as a real number where the fractional part represents part of a second).


FUN Milliseconds_diff|erenceate_time (
     
{date_time} A|fter_date_time ,
     
{date_time} B|efore_date_time ) ==> REAL


Difference between two times measured in milliseconds.


------------------------------------------------- 'extract parts from date'


FUN Only_date || Date_only ( {date_time} DT_source ) ==> {date_time}


Extracting the date part only (nullifying the time).


FUNCTION Year|_of_date (
     
{date_time} DT|_source ) ==> INT


Extracting a year.


FUNCTION Month|_of_date_1_to_12 (
     
{date_time} DT|_source ) ==> INT


Extracting a month.


FUNCTION Day|_of_date_1_to_31 (
     
{date_time} DT|_source ) ==> INT


Extracting a day of month.


FUNCTION Week_day|_of_date (
     
{date_time} DT|_source ) ==> {day}


Extracting a day of week.


FUNCTION Hour|_of_date_0_to_23 (
     
{date_time} DT|_source ) ==> INT


Extracting hours.


FUNCTION Minute|_of_date_0_to_59 (
     
{date_time} DT|_source ) ==> INT


Extracting minutes.


FUNCTION Second|_of_date_0_to_59 (
     
{date_time} DT|_source ) ==> INT


Extracting seconds.


FUNCTION Millisec|ond_of_date_0_to_999 (
     
{date_time} DT|_source ) ==> INT


Extracting milliseconds.


---------------------------------------- 'number of day in year/month/week'

 

FUNCTION Day_of_year|_1_to_366 (
     
{date_time} DT|_source ) ==> INT


Extracting a day of year.


FUNCTION Days_in_month|_28_to_31 (
     
{date_time} DT|_source ) ==> INT


Returns amount of days in a months.


FUNCTION Is_leap_year ( INT Y|ear_of_date ) ==> BOOL



-------------------------------------------------- 'formatting date / time'


FUN S|tr|ing_representing_date_and_time_in_short_default_format (
     
{date_time} DT|_source ) ==> STR


Representing a date/time as a string. Results can be different on different platforms: order of fields, its format, number of fields can differ depending on target language, OS, and user default locale.


FUN Format|ted_date_time (
     
{date_time} DT|_source ,
     
STR F|ormat_string ) ==> STR


Formatting a date and time by a certain format specified.


FUN Month_names|_English (
     
INT M|onth_number_1_to_12 INDEXING STR ) ==> STR


Month names in English: January, February, ...


FUN Weekday_2|_chars ( {day} W|eek_day ) ==> STR


Short 2 characters week days names in English: Su, Mo, Tu ...


FUN Weekday_name|s ( {day} W|eek_day ) ==> STR


Week days names in English: Sunday, Monday, Tuesday ...

END