"O tempora, o lebih!"

Sebagai catatan: Saya meminjam gelar dari Cicero, di Oratio di Catilinam Prima di Senatu Habita .



Cicero Denounces Catiline, lukisan dinding oleh Cesare Maccari, 1882-1888






Dalam kehidupan nyata, kita sering berurusan dengan interval waktu. Janji dengan dokter gigi, reservasi hotel, bahkan istirahat makan siang setiap hari: merencanakan semua ini adalah tugas menyesuaikan slot waktu ke sejumlah slot waktu lainnya.



, . , 1 . . . ,  — ,  — , , , — .



Garis waktu jam sibuk saya dan jam sibuk dokter gigi



, . , . , ?



, . , , .



, Tempus!





,  — Slot. : , from to, DateTime. Slots, AVLTree. , ( ) . , , .



Slots.add/2  — , . , . Slots.merge/2 . , , , , .



Slot: ( ), , . .



Tempus



, . , ; , , , , , .



:



slots =
  [
    Tempus.Slot.wrap(~D|2020-08-07|), # whole day
    %Tempus.Slot{
      from: ~U|2020-08-08 01:01:00Z|, # one minute
      to: ~U|2020-08-08 01:02:00Z|
    },
    %Tempus.Slot{
      from: ~U|2020-08-08 01:03:00Z|, # one minute
      to: ~U|2020-08-08 01:04:00Z|
    }
  ]
  |> Enum.into(%Tempus.Slots{})


0 , , .



Tempus.add(slots, ~U|2020-08-08 01:01:30Z|, 0, :second)
#⇒ ~U[2020-08-08 01:02:00Z]


70 ,  — ~U[2020-08-08 01:00:55Z] —  DateTime (5sec + + 60sec + + 5sec):



Tempus.add(slots, ~U|2020-08-08 01:00:55Z|, 70, :second)
#⇒ ~U[2020-08-08 01:04:05Z]


. , .





Slots.merge/2 Stream . , . , , , , , .



, Slots / Slot —  (, ).



?



, , .






!




All Articles