Module Tdl


module Tdl: sig .. end
The OCaml-TDL library.


Types



type date = {
   year : int; (*complete year*)
   month : int; (*1..12*)
   day : int; (*1..31*)
   hour : int;
   minute : int;
   second : int;
   zone : int; (*in minutes; 60 = UTC+0100*)
   week_day : int; (*0 = sunday; -1 if not given*)
}
val since_epoch : date -> float
val float_to_date : float -> date

type state =
| Done
| Suspended
| Priority_low
| Priority_normal
| Priority_high
val states : state list
All available item states.
val string_of_state : state -> string

type item = {
   mutable item_title : string;
   mutable item_date : date;
   mutable item_enddate : date option; (*milestone date of date when the item state changed to Done.*)
   mutable item_desc : string option;
   mutable item_state : state;
   mutable item_id : int option;
}
type group = {
   mutable group_title : string;
   mutable group_items : item list;
   mutable group_groups : group list;
   mutable group_id : int option;
}

Building and manipulating items and groups


val item : ?id:int ->
title:string ->
state:state ->
?date:date -> ?enddate:date -> ?desc:string -> unit -> item
val group : ?id:int ->
?title:string ->
?items:item list -> ?groups:group list -> unit -> group
val copy_item : item -> item
Return a copy of the given item.
val copy_group : group -> group
Return a copy of the given group, where items and subgroups are also copies.
val remove_item : group -> item -> unit
Remove the given item from the given group.
val remove_group : father:group -> son:group -> unit
Remove the given group son from the given group father .

Reading groups


val group_of_file : string -> group
val group_of_string : string -> group
val group_of_channel : Pervasives.in_channel -> group

Writing groups


val print_group : ?encoding:string -> Format.formatter -> group -> unit
val print_file : ?encoding:string -> string -> group -> unit
encoding : is the name of the encoding of the values of the fields of items and groups. By default it is "ISO-8859-1" but you should give your own if you use another encoding to store the title, description, ... of items and groups. This is used when generating the "<?xml ...>" first line of the document.

Merging


val insert_group : ?path:string list -> group -> group -> unit
insert_group g1 g2 inserts group g2 into g1, that is g1 becomes a subgroup of g1. It is a new subgroup if no group of the same title exists in g1, orelse all subgroups of g2 are recursively inserted into the subgroup of g1 matching the title of g2.
path : can be used to insert g2 in a subgroup of g1, creating subgroups if needed.
val merge_top_groups : group -> group -> group

Filtering



type filter =
| Group of string
| Item of string
| Empty
| State of Tdl_types.state
| Desc of string
| Before of date
| Or of filter * filter
| And of filter * filter
| Not of filter
val filter_of_string : string -> filter
val filter_of_channel : Pervasives.in_channel -> filter
val filter_group : filter -> group -> group

Splitting Todo list by day


val split_by_day : ((int * int * int) * group -> unit) -> group -> unit
split_by_day f tdl splits the given todo list, calling f on each different day and the corresponding todo list. A day is given by a tuple (year, month (1..12), day (1..31)).

Sorting


val compare_item_state : item -> item -> int
Same as Pervasives.compare but for item state (and enddate and date). When the states are the same, the item with the smallest date if first. When the states are both Done, the item with the smallest enddate is last. When the states are different, the order is the following: Priority_high < Priority_normal < Priority_low < Suspended < Done.
val sort_items_by_state : item list -> item list
Sort a list of items using the Tdl.compare_item_state function.