LoginSignup
1
0

More than 5 years have passed since last update.

日本の時刻表現を求める

Posted at

宗教的なプログラミングにどうぞ

import Data.Time.LocalTime

hourJapanese :: TimeOfDay -> String
hourJapanese (TimeOfDay h m _) = z : s : "つ" where
    z = "子丑寅卯辰巳午未申酉戌亥" !! ((h + 1) `div` 2 `mod` 12)
    s
        | h `mod` 2 == 1 && m < 30 = '一'
        | h `mod` 2 == 1 = '二'
        | m < 30 = '三'
        | otherwise = '四'

isOmagaToki :: TimeOfDay -> Bool
isOmagaToki (TimeOfDay h m _) = 17 <= h && h < 19

isUshi_no_koku :: TimeOfDay -> Bool
isUshi_no_koku (TimeOfDay h m _) = 1 <= h && h < 3
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0