[from now] 2014/04/16 23:17:56

[36mdiff --git a/daily_data/20140416.txt b/daily_data/20140416.txt[m
[36mindex 56b3679..4a3bde6 100644[m
[36m--- a/daily_data/20140416.txt[m
[36m+++ b/daily_data/20140416.txt[m
[34m@@ -1,3 +1,7 @@[m
[32m "Meal {name = Just \"\\130\\169\\130\\194\\130\\199\\130\\241\\130\\168\\130\\201\\130\\172\\130\\232\", nutrient = Nutrient {calorie = Just 332.0, protein = Just 7.5, fat = Just 5.4, carbon = Just 63.4}, date = Just 2014-04-16 09:17:31.6319375 \147\140\139\158 (\149W\143\128\142\158)}"[m
[32m  "Meal {name = Just \"\\130\\220\\130\\162\\130\\169\\150\\161\\149t\", nutrient = Nutrient {calorie = Just 128.0, protein = Just 19.2, fat = Just 2.0, carbon = Just 8.3}, date = Just 2014-04-16 12:16:24.472475 \147\140\139\158 (\149W\143\128\142\158)}"[m
[4m+[m[4m "Meal {name = Just \"haagen dazs Crispy Sandwich\", nutrient = Nutrient {calorie = Just 267.0, protein = Just 3.0, fat = Just 19.1, carbon = Just 20.7}, date = Just 2014-04-16 20:21:59.720078 JST}"[m
[4m+[m[4m "Meal {name = Just \"teritama sandwich\", nutrient = Nutrient {calorie = Just 248.0, protein = Just 12.3, fat = Just 8.7, carbon = Just 29.8}, date = Just 2014-04-16 20:22:55.722779 JST}"[m
[4m+[m[4m "Meal {name = Just \"haagen-dazz green tea\", nutrient = Nutrient {calorie = Just 163.0, protein = Just 3.3, fat = Just 10.1, carbon = Just 14.7}, date = Just 2014-04-16 22:34:36.140968 JST}"[m
[4m+[m[4m "Meal {name = Just \"yasai soup\", nutrient = Nutrient {calorie = Just 300.0, protein = Just 15.0, fat = Just 12.0, carbon = Just 0.5}, date = Just 2014-04-16 22:57:23.643728 JST}"[m
[32m  [m
[32m\ No newline at end of file[m
[36mdiff --git a/src/Main b/src/Main[m
[36mindex fb6c6d6..36097f1 100755[m
Binary files a/src/Main and b/src/Main differ
[36mdiff --git a/src/Main.hs b/src/Main.hs[m
[36mindex 79bcd91..f12d1e5 100644[m
[36m--- a/src/Main.hs[m
[36m+++ b/src/Main.hs[m
[34m@@ -32,11 +32,11 @@[m[32m [m[33mmain = do[m
[32m     (cmd:_) <- getArgs[m
[32m     let windows = "C:/HOME/learning_haskell/calorie/daily_data"[m
[32m     let mac = "/Users/theatrical/learning_haskell/calorie_hs/daily_data"[m
[1m-    file <- pure (\x -> windows ++ "/" ++ x ++ ".txt") <*> filename[m
[4m+[m[4m    file <- pure (\x -> mac ++ "/" ++ x ++ ".txt") <*> filename[m
[32m     contents <- if cmd == "workout"[m
[32m                     then W.insertWorkout >>= return . show[m
[32m                     else M.insertMeal >>= return . show[m
[1m-    appendFile file . (++ "\n ") . show $ contents[m
[4m+[m[4m    appendFile file $ (++ "\n ") contents[m
[32m     return ()[m
[32m [m
[32m [m
[from now] 2014/04/17 00:15:35

[36mdiff --git a/daily_data/20140416.txt b/daily_data/20140416.txt[m
[36mindex 4a3bde6..a186911 100644[m
[36m--- a/daily_data/20140416.txt[m
[36m+++ b/daily_data/20140416.txt[m
[34m@@ -4,4 +4,6 @@[m
[32m  "Meal {name = Just \"teritama sandwich\", nutrient = Nutrient {calorie = Just 248.0, protein = Just 12.3, fat = Just 8.7, carbon = Just 29.8}, date = Just 2014-04-16 20:22:55.722779 JST}"[m
[32m  "Meal {name = Just \"haagen-dazz green tea\", nutrient = Nutrient {calorie = Just 163.0, protein = Just 3.3, fat = Just 10.1, carbon = Just 14.7}, date = Just 2014-04-16 22:34:36.140968 JST}"[m
[32m  "Meal {name = Just \"yasai soup\", nutrient = Nutrient {calorie = Just 300.0, protein = Just 15.0, fat = Just 12.0, carbon = Just 0.5}, date = Just 2014-04-16 22:57:23.643728 JST}"[m
[4m+[m[4m Just 660.0[m
[4m+[m[4m Meal {name = Just "protein", nutrient = Nutrient {calorie = Just 130.0, protein = Just 22.0, fat = Nothing, carbon = Nothing}, date = Just 2014-04-17 00:14:44.997367 JST}[m
[32m  [m
[32m\ No newline at end of file[m
[from now] 2014/04/18 02:33:20

[36mdiff --git a/daily_data/20140417.txt b/daily_data/20140417.txt[m
[36mnew file mode 100644[m
[36mindex 0000000..3a23733[m
[36m--- /dev/null[m
[36m+++ b/daily_data/20140417.txt[m
[34m@@ -0,0 +1,66 @@[m
[4m+[m[4m--- "onigiri sekihan"[m
[4m+[m[4m- NAME:[m
[4m+[m[4m    "onigiri sekihan"[m
[4m+[m[4m- DATE:[m
[4m+[m[4m    2014-04-17 11:08:32.4322658 JAPAN[m
[4m+[m[4m- NUTRIENT:[m
[4m+[m[4m    Nutrient {calorie = Just 205.0, protein = Just 5.5, fat = Just 0.8, carbon = Just 43.9}[m
[4m+[m[4m--- "omusubi ohba"[m
[4m+[m[4m- NAME:[m
[4m+[m[4m    "omusubi ohba"[m
[4m+[m[4m- DATE:[m
[4m+[m[4m    2014-04-17 13:08:59.5768183 JAPAN[m
[4m+[m[4m- NUTRIENT:[m
[4m+[m[4m    Nutrient {calorie = Just 200.0, protein = Just 3.5, fat = Just 0.8, carbon = Just 44.8}[m
[4m+[m[4m--- "salada chicken"[m
[4m+[m[4m- NAME:[m
[4m+[m[4m    "salada chicken"[m
[4m+[m[4m- DATE:[m
[4m+[m[4m    2014-04-17 13:08:22.1841114 JAPAN[m
[4m+[m[4m- NUTRIENT:[m
[4m+[m[4m    Nutrient {calorie = Just 131.25, protein = Just 29.75, fat = Just 1.125, carbon = Just 0.375}[m
[4m+[m[4m--- "ookina onigiri"[m
[4m+[m[4m- NAME:[m
[4m+[m[4m    "ookina onigiri"[m
[4m+[m[4m- DATE:[m
[4m+[m[4m    2014-04-17 18:19:10.6646781 JAPAN[m
[4m+[m[4m- NUTRIENT:[m
[4m+[m[4m    Nutrient {calorie = Just 296.0, protein = Just 6.8, fat = Just 2.6, carbon = Just 61.4}[m
[4m+[m[4m--- Meal[m[7m [m
[4m+[m[4m- NAME:[m[7m [m
[4m+[m[4m    "kakinotane"[m
[4m+[m[4m- DATE:[m[7m [m
[4m+[m[4m    2014-04-17 19:49:03.410438 JAPAN[m
[4m+[m[4m- NUTRIENT:[m[7m [m
[4m+[m[4m    Nutrient {calorie = Just 303.0, protein = Just 10.0, fat = Just 14.5, carbon = Just 33.2}[m
[4m+[m[4m --- Meal[m[7m [m
[4m+[m[4m- NAME:[m[7m [m
[4m+[m[4m    "haagen-dazs"[m
[4m+[m[4m- DATE:[m[7m [m
[4m+[m[4m    2014-04-17 20:35:36.958273 JAPAN[m
[4m+[m[4m- NUTRIENT:[m[7m [m
[4m+[m[4m    Nutrient {calorie = Just 168.0, protein = Just 2.4, fat = Just 10.7, carbon = Just 14.1}[m
[4m+[m[4m --- Wokout[m
[4m+[m[4m- Just 924.0[m
[4m+[m[4m --- Meal[m[7m [m
[4m+[m[4m- NAME:[m[7m [m
[4m+[m[4m    "miso soup"[m
[4m+[m[4m- DATE:[m[7m [m
[4m+[m[4m    2014-04-18 01:34:38.410557 JAPAN[m
[4m+[m[4m- NUTRIENT:[m[7m [m
[4m+[m[4m    Nutrient {calorie = Just 300.0, protein = Just 10.0, fat = Just 9.0, carbon = Just 2.0}[m
[4m+[m[4m --- Meal[m[7m [m
[4m+[m[4m- NAME:[m[7m [m
[4m+[m[4m    "haagen dazs vanila"[m
[4m+[m[4m- DATE:[m[7m [m
[4m+[m[4m    2014-04-18 02:14:12.336889 JAPAN[m
[4m+[m[4m- NUTRIENT:[m[7m [m
[4m+[m[4m    Nutrient {calorie = Just 167.0, protein = Just 3.1, fat = Just 10.0, carbon = Just 16.1}[m
[4m+[m[4m --- Meal[m[7m [m
[4m+[m[4m- NAME:[m[7m [m
[4m+[m[4m    "haagen dazs rum raisin"[m
[4m+[m[4m- DATE:[m[7m [m
[4m+[m[4m    2014-04-18 02:19:54.582775 JAPAN[m
[4m+[m[4m- NUTRIENT:[m[7m [m
[4m+[m[4m    Nutrient {calorie = Just 168.0, protein = Just 3.0, fat = Just 10.0, carbon = Just 24.0}[m
[4m+[m[7m [m
[32m\ No newline at end of file[m
[36mdiff --git a/src/Main b/src/Main[m
[36mindex 36097f1..c18eb05 100755[m
Binary files a/src/Main and b/src/Main differ
[36mdiff --git a/src/Main.hs b/src/Main.hs[m
[36mindex f12d1e5..322f331 100644[m
[36m--- a/src/Main.hs[m
[36m+++ b/src/Main.hs[m
[34m@@ -7,6 +7,8 @@[m[32m [m[33mimport qualified Util.Translate as T[m
[32m import Data.Time[m
[32m import Control.Applicative[m
[32m import System.Environment[m
[4m+[m[4mimport Control.Monad[m
[4m+[m[4mimport Data.List[m
[32m [m
[32m [m
[32m filename :: IO String[m
[34m@@ -29,14 +31,22 @@[m[32m [m[33mzeroFill len n = if l >= len[m
[32m [m
[32m main :: IO ()[m
[32m main = do[m
[1m-    (cmd:_) <- getArgs[m
[4m+[m[4m    x <- getArgs[m
[4m+[m[4m    let cmd  = if length x > 0 then head x else ""[m
[32m     let windows = "C:/HOME/learning_haskell/calorie/daily_data"[m
[32m     let mac = "/Users/theatrical/learning_haskell/calorie_hs/daily_data"[m
[1m-    file <- pure (\x -> mac ++ "/" ++ x ++ ".txt") <*> filename[m
[1m-    contents <- if cmd == "workout"[m
[1m-                    then W.insertWorkout >>= return . show[m
[1m-                    else M.insertMeal >>= return . show[m
[1m-    appendFile file $ (++ "\n ") contents[m
[4m+[m[4m    file <- pure (\n -> mac ++ "/" ++ n ++ ".txt") <*> filename[m
[4m+[m[4m    contents <- case cmd of[m
[4m+[m[4m                        "workout" -> W.insertWorkout >>= return . ("--- Wokout\n- " ++) .  show[m
[4m+[m[4m                        "add"     -> M.insertMeal >>= return . M.showMeal[m
[4m+[m[4m                        _         -> return ""[m
[4m+[m[4m    when (contents /= "") $ appendFile file . (++ "\n ") $ contents[m
[4m+[m[4m    appededContents <- fmap lines $ readFile file[m
[4m+[m[4m    mapM_ (putStrLn . (++ "\n"). show) appededContents[m
[4m+[m[4m    putStrLn $ "##### Total #####\n"[m
[4m+[m[4m                    ++ (show[m
[4m+[m[4m                        . foldl1 M.nAdd[m
[4m+[m[4m                        . map (read :: String -> M.Nutrient)[m
[4m+[m[4m                        . filter (isInfixOf "Nutrient")[m
[4m+[m[4m                        $ appededContents)[m
[32m     return ()[m
[1m-[m
[1m-[m
[36mdiff --git a/src/Meal.hs b/src/Meal.hs[m
[36mindex 4d81068..e4b5a70 100644[m
[36m--- a/src/Meal.hs[m
[36m+++ b/src/Meal.hs[m
[34m@@ -7,6 +7,7 @@[m[32m [m[33mmodule Meal ([m
[32m             , insertNutrient[m
[32m             , defaultNutrient[m
[32m             , defaultMeal[m
[4m+[m[4m            , showMeal[m
[32m             , calorieCal[m
[32m             , nAdd[m
[32m             , nMal[m
[34m@@ -96,14 +97,33 @@[m[32m [m[33minstance Ord T.ZonedTime where[m
[32m defaultMeal :: Meal[m
[32m defaultMeal = Meal{name = Nothing, nutrient = defaultNutrient, date = Nothing}[m
[32m [m
[4m+[m[4mjapan = T.TimeZone 540 False "JAPAN"[m
[32m insertMeal :: IO Meal[m
[32m insertMeal = do[m
[32m         n <- prompt "name" :: IO (Maybe String)[m
[32m         nu <- insertNutrient[m
[1m-        d <- T.getZonedTime[m
[4m+[m[4m        d <- fmap (T.utcToZonedTime japan) T.getCurrentTime[m
[32m         return defaultMeal{name = n, nutrient = nu, date = Just d}[m
[32m     where[m
[32m         prompt s = do[m
[32m                     putStrLn $ s ++ " is?"[m
[32m                     n <- getLine[m
[32m                     return $ Just n[m
[4m+[m
[4m+[m[4mshowMeal :: Meal -> String[m
[4m+[m[4mshowMeal m = "--- Meal \n"[m
[4m+[m[4m              ++ "- NAME: " ++ "\n"[m
[4m+[m[4m              ++ "    " ++ name' ++ "\n"[m
[4m+[m[4m              ++ "- DATE: " ++ "\n"[m
[4m+[m[4m              ++ "    " ++ date' ++ "\n"[m
[4m+[m[4m              ++ "- NUTRIENT: " ++ "\n"[m
[4m+[m[4m              ++ "    " ++ nutrient'[m
[4m+[m[4m        where[m
[4m+[m[4m          show' cs = case cs of[m
[4m+[m[4m                        Just c -> show c[m
[4m+[m[4m                        _      -> ""[m
[4m+[m[4m          name' = show' . name $ m[m
[4m+[m[4m          nutrient' = show . nutrient $ m[m
[4m+[m[4m          date' = show' . date $ m[m
[7m+[m
[7m+[m
[36mdiff --git a/src/workout.hs b/src/workout.hs[m
[36mindex 4fb4405..ad7c6a1 100644[m
[36m--- a/src/workout.hs[m
[36m+++ b/src/workout.hs[m
[34m@@ -1,7 +1,7 @@[m
[32m module Workout([m
[32m               Workout(..)[m
[32m               , lossCalorie[m
[1m-							, insertWorkout[m
[4m+[m[4m              , insertWorkout[m
[32m               , ) where[m
[32m [m
[32m import Data.Calorie[m
[34m@@ -13,12 +13,10 @@[m[32m [m[33mlossCalorie _ _ _  = Nothing[m
[32m [m
[32m insertWorkout :: IO Calorie[m
[32m insertWorkout = do[m
[1m-	putStrLn "Workout Type"[m
[1m-	wType <- fmap read getLine :: IO Workout[m
[1m-	putStrLn "Weight (kg)"[m
[1m-	kg <- fmap read getLine :: IO Double[m
[1m-	putStrLn "Distance (km)"[m
[1m-	distance <- fmap read getLine :: IO Double[m
[1m-	return $ lossCalorie wType kg distance[m
[1m-[m
[1m-[m
[4m+[m[4m  putStrLn "Workout Type"[m
[4m+[m[4m  wType <- fmap read getLine :: IO Workout[m
[4m+[m[4m  putStrLn "Weight (kg)"[m
[4m+[m[4m  kg <- fmap read getLine :: IO Double[m
[4m+[m[4m  putStrLn "Distance (km)"[m
[4m+[m[4m  distance <- fmap read getLine :: IO Double[m
[4m+[m[4m  return $ lossCalorie wType kg distance[m