Public Vars

Back

last-in-month (clj)

(source)

function

(last-in-month day-of-week) (last-in-month t day-of-week)

Examples

tick
(ns tick.api-test
  (:require
    [clojure.test
     :refer [deftest is testing run-tests]
     :refer-macros [deftest is testing run-tests]]
    [tick.core :as t]
    [tick.locale-en-us]
    [tick.protocols :as p]
    [cljc.java-time.clock]
    [cljc.java-time.instant]
    [cljc.java-time.day-of-week]
    [cljc.java-time.month]
    [cljc.java-time.year]
    #?@(:cljs [[java.time :refer [Instant]]]))
  #?(:clj
     (:import [java.time Instant])))

(deftest adjusters
  (is (= (t/date "2022-01-15")
         (t/day-of-week-in-month (t/date "2022-01-01") 3 t/SATURDAY)))
  (is (= (t/date "2022-01-01")
         (t/first-in-month (t/date "2022-01-01") t/SATURDAY)))
  (is (= (t/date "2022-01-29")
         (t/last-in-month (t/date "2022-01-01") t/SATURDAY)))
  (is (= (t/date "2022-01-08")
         (t/next (t/date "2022-01-01") t/SATURDAY)))
  (is (= (t/date "2022-01-01")
         (t/next-or-same (t/date "2022-01-01") t/SATURDAY)))
  (is (= (t/date "2021-12-25")
         (t/previous (t/date "2022-01-01") t/SATURDAY)))
  (is (= (t/date "2022-01-01")
         (t/previous-or-same (t/date "2022-01-01") t/SATURDAY))))