Command-line and Emacs Calendar Client
1val default_timezone : (unit -> Timedesc.Time_zone.t) ref 2(** Default timezone to use for date operations. Defaults to the local timezone 3 of the system, falling back to UTC if local timezone cannot be determined. 4*) 5 6val timedesc_to_ptime : Timedesc.t -> Ptime.t 7(** Convert a Timedesc.t to a Ptime.t. *) 8 9val ptime_to_timedesc : ?tz:Timedesc.Time_zone.t -> Ptime.t -> Timedesc.t 10(** Convert a Ptime.t to a Timedesc.t with the specified timezone. If no 11 timezone is provided, uses the default_timezone. *) 12 13val get_today : (?tz:Timedesc.Time_zone.t -> unit -> Ptime.t) ref 14(** Get the current date at midnight in the specified timezone. If no timezone 15 is provided, uses the default_timezone. This is a reference to support 16 testing. Returns the date or raises an exception if the date cannot be 17 determined. *) 18 19val to_end_of_day : Ptime.t -> Ptime.t 20(** Converts a date with midnight time (00:00:00) to the same date with 21 end-of-day time (23:59:59). This is particularly useful for making "to" 22 dates in a range inclusive, addressing the common UX expectation that 23 specifying "--to 2025-04-01" would include events occurring on April 1st. *) 24 25val add_days : Ptime.t -> int -> Ptime.t 26(** Add specified number of days to a date. Raises an exception if the date 27 cannot be calculated. *) 28 29val add_weeks : Ptime.t -> int -> Ptime.t 30(** Add specified number of weeks to a date. Raises an exception if the date 31 cannot be calculated. *) 32 33val add_months : Ptime.t -> int -> Ptime.t 34(** Add specified number of months to a date. Raises an exception if the date 35 cannot be calculated. *) 36 37val add_years : Ptime.t -> int -> Ptime.t 38(** Add specified number of months to a date. Raises an exception if the date 39 cannot be calculated. *) 40 41val get_start_of_week : Ptime.t -> Ptime.t 42(** Get the start of the week (Monday) for the given date. Raises an exception 43 if the date cannot be calculated. *) 44 45val get_start_of_current_week : ?tz:Timedesc.Time_zone.t -> unit -> Ptime.t 46(** Get the start of the current week in the specified timezone. If no timezone 47 is provided, uses the default_timezone. Raises an exception if the date 48 cannot be calculated. *) 49 50val get_start_of_next_week : ?tz:Timedesc.Time_zone.t -> unit -> Ptime.t 51(** Get the start of next week in the specified timezone. If no timezone is 52 provided, uses the default_timezone. Raises an exception if the date cannot 53 be calculated. *) 54 55val get_end_of_week : Ptime.t -> Ptime.t 56(** Get the end of the week (Monday) for the given date. Raises an exception if 57 the date cannot be calculated. *) 58 59val get_end_of_current_week : ?tz:Timedesc.Time_zone.t -> unit -> Ptime.t 60(** Get the end of the current week in the specified timezone. If no timezone is 61 provided, uses the default_timezone. Raises an exception if the date cannot 62 be calculated. *) 63 64val get_end_of_next_week : ?tz:Timedesc.Time_zone.t -> unit -> Ptime.t 65(** Get the end of next week in the specified timezone. If no timezone is 66 provided, uses the default_timezone. Raises an exception if the date cannot 67 be calculated. *) 68 69val get_start_of_month : Ptime.t -> Ptime.t 70(** Get the start of the month for the given date. Raises an exception if the 71 date cannot be calculated. *) 72 73val get_start_of_current_month : ?tz:Timedesc.Time_zone.t -> unit -> Ptime.t 74(** Get the start of the current month in the specified timezone. If no timezone 75 is provided, uses the default_timezone. Raises an exception if the date 76 cannot be calculated. *) 77 78val get_start_of_next_month : ?tz:Timedesc.Time_zone.t -> unit -> Ptime.t 79(** Get the start of next month in the specified timezone. If no timezone is 80 provided, uses the default_timezone. Raises an exception if the date cannot 81 be calculated. *) 82 83val get_end_of_current_month : ?tz:Timedesc.Time_zone.t -> unit -> Ptime.t 84(** Get the end of the current month in the specified timezone. If no timezone 85 is provided, uses the default_timezone. Raises an exception if the date 86 cannot be calculated. *) 87 88val get_end_of_next_month : ?tz:Timedesc.Time_zone.t -> unit -> Ptime.t 89(** Get the end of next month in the specified timezone. If no timezone is 90 provided, uses the default_timezone. Raises an exception if the date cannot 91 be calculated. *) 92 93val get_end_of_month : Ptime.t -> Ptime.t 94(** Get the end of the month for the given date. Raises an exception if the date 95 cannot be calculated. *) 96 97val convert_relative_date_formats : 98 ?tz:Timedesc.Time_zone.t -> 99 today:bool -> 100 tomorrow:bool -> 101 week:bool -> 102 month:bool -> 103 unit -> 104 (Ptime.t * Ptime.t) option 105(** Converts relative date formats to determine from/to dates in the specified 106 timezone. If no timezone is provided, uses the default_timezone. Returns a 107 tuple of (start_date, end_date) or raises an exception if the dates could 108 not be determined. **) 109 110val parse_date : 111 ?tz:Timedesc.Time_zone.t -> 112 string -> 113 [ `To | `From ] -> 114 (Ptime.t, [> `Msg of string ]) result 115(** Parse a date string that could be ISO format (YYYY-MM-DD) or a relative 116 expression in the specified timezone. If no timezone is provided, uses the 117 default_timezone. 118 119 Supported formats: 120 - ISO format: "YYYY-MM-DD" 121 - Relative expressions: 122 - "today" - Current day 123 - "tomorrow" - Next day 124 - "yesterday" - Previous day 125 - "this-week" - Start of current week 126 - "next-week" - Start of next week 127 - "this-month" - Start of current month 128 - "next-month" - Start of next month 129 - "+Nd" - N days from today (e.g., "+7d" for a week from today) 130 - "-Nd" - N days before today (e.g., "-7d" for a week ago) 131 - "+Nw" - N weeks from today 132 - "+Nm" - N months from today *) 133 134val parse_time : string -> (int * int * int, [> `Msg of string ]) result 135(** Parse a time string in HH:MM or HH:MM:SS format. Returns Ok with (hour, 136 minute, second) or Error with a message. **) 137 138val parse_date_time : 139 ?tz:Timedesc.Time_zone.t -> 140 date:string -> 141 time:string -> 142 [ `To | `From ] -> 143 (Ptime.t, [> `Msg of string ]) result 144(** Parse a date and time string in the specified timezone. If no timezone is 145 provided, uses the default_timezone. *) 146 147val ptime_of_ical : Icalendar.date_or_datetime -> Ptime.t