From 30235491eff93caf99761c2d48d60a89f1b9d7c7 Mon Sep 17 00:00:00 2001 From: Denis Ignatovich Date: Fri, 21 Jul 2017 15:43:33 +0100 Subject: [PATCH 1/3] [feat] adding missing comparison functions --- src-core/datetime.ml | 101 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/src-core/datetime.ml b/src-core/datetime.ml index b4c81078..ea6b1ef1 100644 --- a/src-core/datetime.ml +++ b/src-core/datetime.ml @@ -164,6 +164,36 @@ let is_valid_localmktdate ( lmd : fix_localmktdate ) = 1 <= lmd.localmktdate_day && lmd.localmktdate_day <= 31 ;; +let utc_localmktdateGreaterThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = + if lmdOne.localmktdate_year > lmdTwo.localmktdate_year then true else + if lmdOne.localmktdate_year < lmdTwo.localmktdate_year then false else + if lmdOne.localmktdate_month > lmdTwo.localmktdate_month then true else + if lmdOne.localmktdate_month < lmdTwo.localmktdate_month then false else + lmdOne.localmktdate_day > lmdTwo.localmktdate_day +;; + +let utc_localmktdateLessThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = + if lmdOne.localmktdate_year < lmdTwo.localmktdate_year then true else + if lmdOne.localmktdate_year > lmdTwo.localmktdate_year then false else + if lmdOne.localmktdate_month < lmdTwo.localmktdate_month then true else + if lmdOne.localmktdate_month > lmdTwo.localmktdate_month then false else + lmdOne.localmktdate_day < lmdTwo.localmktdate_day +;; + +let utc_localmktdateEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = + lmdOne.localmktdate_year = lmdTwo.localmktdate_year && + lmdOne.localmktdate_month = lmdTwo.localmktdate_month && + lmdOne.localmktdate_day = lmdTwo.localmktdate_day +;; + +let utc_localmktdateGreaterThanEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = + utc_localmktdateGreaterThan (lmdOne, lmdTwo) || utc_localmktdateEqual ( lmdOne, lmdTwo ) +;; + +let utc_localmktdateLessThanEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = + utc_localmktdateLessThan (lmdOne, lmdTwo) || utc_localmktdateEqual ( lmdOne, lmdTwo ) +;; + (** Week *) type fix_week = | Week_1 @@ -213,6 +243,46 @@ let is_valid_monthyear ( my : fix_monthyear ) = ) ;; +(** TODO: Add support for weeks! *) +let utc_monthyearGreaterThan ( myOne, myTwo : fix_monthyear * fix_monthyear ) = + if myOne.monthyear_year > myTwo.monthyear_year then true else + if myOne.monthyear_year < myTwo.monthyear_year then false else + if myOne.monthyear_month > myTwo.monthyear_month then true else + if myOne.monthyear_month < myTwo.monthyear_month then false else + match myOne.monthyear_day, myTwo.monthyear_day with + | None, None -> false + | Some d, None -> true + | None, Some d -> false + | Some d_one, Some d_two -> d_one > d_two +;; + +let utc_monthyearLessThan ( myOne, myTwo : fix_monthyear * fix_monthyear ) = + if myOne.monthyear_year < myTwo.monthyear_year then true else + if myOne.monthyear_year > myTwo.monthyear_year then false else + if myOne.monthyear_month < myTwo.monthyear_month then true else + if myOne.monthyear_month > myTwo.monthyear_month then false else + match myOne.monthyear_day, myTwo.monthyear_day with + | None, None -> false + | Some d, None -> false + | None, Some d -> true + | Some d_one, Some d_two -> d_one > d_two +;; + +let utc_monthyearEqual ( myOne, myTwo : fix_monthyear * fix_monthyear ) = + myOne.monthyear_year = myTwo.monthyear_year && + myOne.monthyear_month = myTwo.monthyear_month && + myOne.monthyear_day = myTwo.monthyear_day +;; + +let utc_monthyearGreaterThanEqual ( myOne, myTwo : fix_monthyear * fix_monthyear ) = + utc_monthyearGreaterThan (myOne, myTwo) || utc_monthyearEqual (myOne, myTwo) +;; + +let utc_monthyearLessThanEqual ( myOne, myTwo : fix_monthyear * fix_monthyear ) = + utc_monthyearLessThan (myOne, myTwo) || utc_monthyearEqual (myOne, myTwo) +;; + + (** UTC Timeonly *) type fix_utctimeonly = { utc_timeonly_hour : int; @@ -310,6 +380,37 @@ let is_valid_utcdateonly ( d : fix_utcdateonly ) = 1 <= d.utc_dateonly_day && d.utc_dateonly_day <= 31 ;; +let utcdateonly_GreaterThan ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = + if dOne.utc_dateonly_year > dTwo.utc_dateonly_year then true else + if dOne.utc_dateonly_year < dTwo.utc_dateonly_year then false else + if dOne.utc_dateonly_month > dTwo.utc_dateonly_month then true else + if dOne.utc_dateonly_month < dTwo.utc_dateonly_month then false else + dOne.utc_dateonly_day > dTwo.utc_dateonly_day +;; + +let utcdateonly_LessThan ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = + if dOne.utc_dateonly_year > dTwo.utc_dateonly_year then false else + if dOne.utc_dateonly_year < dTwo.utc_dateonly_year then true else + if dOne.utc_dateonly_month > dTwo.utc_dateonly_month then false else + if dOne.utc_dateonly_month < dTwo.utc_dateonly_month then true else + dOne.utc_dateonly_day < dTwo.utc_dateonly_day +;; + +let utddateonly_Equal ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = + dOne.utc_dateonly_year = dTwo.utc_dateonly_year && + dOne.utc_dateonly_month = dTwo.utc_dateonly_year && + dOne.utc_dateonly_day = dTwo.utc_dateonly_month +;; + +let utddateonly_GreaterThanEqual ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = + utcdateonly_GreaterThan ( dOne, dTwo ) || utddateonly_Equal ( dOne, dTwo ) +;; + +let utddateonly_LessThanEqual ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = + utcdateonly_LessThan ( dOne, dTwo ) || utddateonly_Equal ( dOne, dTwo ) +;; + + (** Duration *) type fix_duration = { dur_years : int option; From 5a7da939747d30576c5dc104f4dc03cd440d4205 Mon Sep 17 00:00:00 2001 From: Denis Ignatovich Date: Fri, 21 Jul 2017 16:05:56 +0100 Subject: [PATCH 2/3] fixing function names to be compatible with IPL rules --- src-core/datetime.ml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src-core/datetime.ml b/src-core/datetime.ml index ea6b1ef1..704c767b 100644 --- a/src-core/datetime.ml +++ b/src-core/datetime.ml @@ -164,7 +164,7 @@ let is_valid_localmktdate ( lmd : fix_localmktdate ) = 1 <= lmd.localmktdate_day && lmd.localmktdate_day <= 31 ;; -let utc_localmktdateGreaterThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = +let localmktdateGreaterThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = if lmdOne.localmktdate_year > lmdTwo.localmktdate_year then true else if lmdOne.localmktdate_year < lmdTwo.localmktdate_year then false else if lmdOne.localmktdate_month > lmdTwo.localmktdate_month then true else @@ -172,7 +172,7 @@ let utc_localmktdateGreaterThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localm lmdOne.localmktdate_day > lmdTwo.localmktdate_day ;; -let utc_localmktdateLessThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = +let localmktdateLessThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = if lmdOne.localmktdate_year < lmdTwo.localmktdate_year then true else if lmdOne.localmktdate_year > lmdTwo.localmktdate_year then false else if lmdOne.localmktdate_month < lmdTwo.localmktdate_month then true else @@ -180,18 +180,18 @@ let utc_localmktdateLessThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktd lmdOne.localmktdate_day < lmdTwo.localmktdate_day ;; -let utc_localmktdateEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = +let localmktdateEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = lmdOne.localmktdate_year = lmdTwo.localmktdate_year && lmdOne.localmktdate_month = lmdTwo.localmktdate_month && lmdOne.localmktdate_day = lmdTwo.localmktdate_day ;; -let utc_localmktdateGreaterThanEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = - utc_localmktdateGreaterThan (lmdOne, lmdTwo) || utc_localmktdateEqual ( lmdOne, lmdTwo ) +let localmktdateGreaterThanEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = + localmktdateGreaterThan (lmdOne, lmdTwo) || localmktdateEqual ( lmdOne, lmdTwo ) ;; -let utc_localmktdateLessThanEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = - utc_localmktdateLessThan (lmdOne, lmdTwo) || utc_localmktdateEqual ( lmdOne, lmdTwo ) +let localmktdateLessThanEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = + localmktdateLessThan (lmdOne, lmdTwo) || localmktdateEqual ( lmdOne, lmdTwo ) ;; (** Week *) @@ -244,7 +244,7 @@ let is_valid_monthyear ( my : fix_monthyear ) = ;; (** TODO: Add support for weeks! *) -let utc_monthyearGreaterThan ( myOne, myTwo : fix_monthyear * fix_monthyear ) = +let monthyear_GreaterThan ( myOne, myTwo : fix_monthyear * fix_monthyear ) = if myOne.monthyear_year > myTwo.monthyear_year then true else if myOne.monthyear_year < myTwo.monthyear_year then false else if myOne.monthyear_month > myTwo.monthyear_month then true else @@ -256,7 +256,7 @@ let utc_monthyearGreaterThan ( myOne, myTwo : fix_monthyear * fix_monthyear ) = | Some d_one, Some d_two -> d_one > d_two ;; -let utc_monthyearLessThan ( myOne, myTwo : fix_monthyear * fix_monthyear ) = +let monthyear_LessThan ( myOne, myTwo : fix_monthyear * fix_monthyear ) = if myOne.monthyear_year < myTwo.monthyear_year then true else if myOne.monthyear_year > myTwo.monthyear_year then false else if myOne.monthyear_month < myTwo.monthyear_month then true else @@ -268,18 +268,18 @@ let utc_monthyearLessThan ( myOne, myTwo : fix_monthyear * fix_monthyear ) = | Some d_one, Some d_two -> d_one > d_two ;; -let utc_monthyearEqual ( myOne, myTwo : fix_monthyear * fix_monthyear ) = +let monthyear_Equal ( myOne, myTwo : fix_monthyear * fix_monthyear ) = myOne.monthyear_year = myTwo.monthyear_year && myOne.monthyear_month = myTwo.monthyear_month && myOne.monthyear_day = myTwo.monthyear_day ;; -let utc_monthyearGreaterThanEqual ( myOne, myTwo : fix_monthyear * fix_monthyear ) = - utc_monthyearGreaterThan (myOne, myTwo) || utc_monthyearEqual (myOne, myTwo) +let monthyear_GreaterThanEqual ( myOne, myTwo : fix_monthyear * fix_monthyear ) = + monthyear_GreaterThan (myOne, myTwo) || monthyear_Equal (myOne, myTwo) ;; -let utc_monthyearLessThanEqual ( myOne, myTwo : fix_monthyear * fix_monthyear ) = - utc_monthyearLessThan (myOne, myTwo) || utc_monthyearEqual (myOne, myTwo) +let monthyear_LessThanEqual ( myOne, myTwo : fix_monthyear * fix_monthyear ) = + monthyear_LessThan (myOne, myTwo) || monthyear_Equal (myOne, myTwo) ;; @@ -396,18 +396,18 @@ let utcdateonly_LessThan ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = dOne.utc_dateonly_day < dTwo.utc_dateonly_day ;; -let utddateonly_Equal ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = +let utcdateonly_Equal ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = dOne.utc_dateonly_year = dTwo.utc_dateonly_year && dOne.utc_dateonly_month = dTwo.utc_dateonly_year && dOne.utc_dateonly_day = dTwo.utc_dateonly_month ;; let utddateonly_GreaterThanEqual ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = - utcdateonly_GreaterThan ( dOne, dTwo ) || utddateonly_Equal ( dOne, dTwo ) + utcdateonly_GreaterThan ( dOne, dTwo ) || utcdateonly_Equal ( dOne, dTwo ) ;; let utddateonly_LessThanEqual ( dOne, dTwo : fix_utcdateonly * fix_utcdateonly ) = - utcdateonly_LessThan ( dOne, dTwo ) || utddateonly_Equal ( dOne, dTwo ) + utcdateonly_LessThan ( dOne, dTwo ) || utcdateonly_Equal ( dOne, dTwo ) ;; From ca63c8e4b96c3faf59ae72c98e2faaf795021d77 Mon Sep 17 00:00:00 2001 From: Denis Ignatovich Date: Fri, 21 Jul 2017 16:07:18 +0100 Subject: [PATCH 3/3] fixed localmktdate --- src-core/datetime.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src-core/datetime.ml b/src-core/datetime.ml index 704c767b..2ae787a8 100644 --- a/src-core/datetime.ml +++ b/src-core/datetime.ml @@ -164,7 +164,7 @@ let is_valid_localmktdate ( lmd : fix_localmktdate ) = 1 <= lmd.localmktdate_day && lmd.localmktdate_day <= 31 ;; -let localmktdateGreaterThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = +let localmktdate_GreaterThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = if lmdOne.localmktdate_year > lmdTwo.localmktdate_year then true else if lmdOne.localmktdate_year < lmdTwo.localmktdate_year then false else if lmdOne.localmktdate_month > lmdTwo.localmktdate_month then true else @@ -172,7 +172,7 @@ let localmktdateGreaterThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktda lmdOne.localmktdate_day > lmdTwo.localmktdate_day ;; -let localmktdateLessThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = +let localmktdate_LessThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = if lmdOne.localmktdate_year < lmdTwo.localmktdate_year then true else if lmdOne.localmktdate_year > lmdTwo.localmktdate_year then false else if lmdOne.localmktdate_month < lmdTwo.localmktdate_month then true else @@ -180,18 +180,18 @@ let localmktdateLessThan ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate lmdOne.localmktdate_day < lmdTwo.localmktdate_day ;; -let localmktdateEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = +let localmktdate_Equal ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = lmdOne.localmktdate_year = lmdTwo.localmktdate_year && lmdOne.localmktdate_month = lmdTwo.localmktdate_month && lmdOne.localmktdate_day = lmdTwo.localmktdate_day ;; -let localmktdateGreaterThanEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = - localmktdateGreaterThan (lmdOne, lmdTwo) || localmktdateEqual ( lmdOne, lmdTwo ) +let localmktdate_GreaterThanEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = + localmktdate_GreaterThan (lmdOne, lmdTwo) || localmktdate_Equal ( lmdOne, lmdTwo ) ;; let localmktdateLessThanEqual ( lmdOne, lmdTwo : fix_localmktdate * fix_localmktdate ) = - localmktdateLessThan (lmdOne, lmdTwo) || localmktdateEqual ( lmdOne, lmdTwo ) + localmktdate_LessThan (lmdOne, lmdTwo) || localmktdate_Equal ( lmdOne, lmdTwo ) ;; (** Week *)