Skip to content

Instantly share code, notes, and snippets.

@blackawa
Created September 1, 2018 10:41
Show Gist options
  • Save blackawa/8ecca08549c67126b4cd7a3b31a45a12 to your computer and use it in GitHub Desktop.
Save blackawa/8ecca08549c67126b4cd7a3b31a45a12 to your computer and use it in GitHub Desktop.
雑な西暦->和暦変換関数
(defn- 西暦->和暦 [西暦]
(let [year (read-string 西暦)]
(cond
;; 平成
(<= 0 (- year 1988))
{:和暦 "平成"
:年 (- year 1988)}
;; 昭和
(<= 0 (- year 1925))
{:和暦 "昭和"
:年 (- year 1925)}
;; 大正
(<= 0 (- year 1911))
{:和暦 "大正"
:年 (- year 1911)}
:else
{:和暦 "不明"
:年 year})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment