/swift-date-macro

Macro for converting String to Date safely

Primary LanguageSwiftMIT LicenseMIT

swift-date-macro

Macro for converting String to Date safely

Usage

let date = #date("2023/11/27", dateFormat: "yyyy/MM/dd")

Entering the wrong date format like this causes a compile error

let date = #date("202311-11", dateFormat: "yyyy-MM-dd")
        // ┬───────────────────────────────────────────
        // ╰─ 🛑 malformed date or dateFormat: 202311-11, yyyy-MM-dd