Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Support using "Mon", "Tue", etc aswell as "today", "tomorrow"
Works well, but not having hlint means my code is messy. Could do with a |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/issue1 | trunk | master |
Files: | files | file ages | folders |
SHA3-256: |
beb9ee5fcaec1752e860dc9edf121c71 |
User & Date: | atomicules 2020-05-14 20:47:43 |
Context
2020-05-15
| ||
08:29 |
Handle any case of short day: Mon, mon, MON, etc.
Just because it'll be easier for me to use lowercase. check-in: 386fcc875a user: atomicules tags: master, origin/issue1, trunk | |
2020-05-14
| ||
20:47 |
Support using "Mon", "Tue", etc aswell as "today", "tomorrow"
Works well, but not having hlint means my code is messy. Could do with a | |
06:16 |
Add `nextweek` command to move todos to "next" Monday
I.e. whatever day of the week the todo is on it'll be moved to the next Monday. | |
Changes
Changes to haskerdeux.hs.
︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | main = do (date:command:argList) <- getArgs time <- getClockTime >>= toCalendarTime --https://wiki.haskell.org/Unix_tools/Date let todays_date = formatCalendarTime defaultTimeLocale "%Y-%m-%d" time let tomorrows_date = show (addDays 1 $ read todays_date::Data.Time.Day) let todos_date | date == "today" = todays_date | date == "tomorrow" = tomorrows_date | otherwise = date when ((command `elem` ["todos"] && Data.List.null argList) || (command `elem` ["new", "crossoff", "putoff", "delete", "nextweek"] && length argList == 1) || (command == "moveto" && length argList == 2)) $ do token <- login dispatch command (token, todos_date:argList) readnetrc = do home <- getHomeDirectory netrc <- lines Control.Applicative.<$> readFile (home ++ "/.netrc") let netrc' = dropWhile (not . ("teuxdeux" `isInfixOf`)) netrc let (username, password) = if "login" `isInfixOf` head netrc' -- if entry is on one line | > > > > > > > > > > > > > > > > > > > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | main = do (date:command:argList) <- getArgs time <- getClockTime >>= toCalendarTime --https://wiki.haskell.org/Unix_tools/Date let todays_date = formatCalendarTime defaultTimeLocale "%Y-%m-%d" time let tomorrows_date = show (addDays 1 $ read todays_date::Data.Time.Day) let todos_date | date == "today" = todays_date | date == "tomorrow" = tomorrows_date | date `elem` ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] = parseday (date, todays_date) | otherwise = date when ((command `elem` ["todos"] && Data.List.null argList) || (command `elem` ["new", "crossoff", "putoff", "delete", "nextweek"] && length argList == 1) || (command == "moveto" && length argList == 2)) $ do token <- login dispatch command (token, todos_date:argList) parseday (future_day, todays_date) = do let days_map = fromList [ ("Mon", 0) , ("Tue", 1) , ("Wed", 2) , ("Thu", 3) , ("Fri", 4) , ("Sat", 5) , ("Sun", 6)] let time_from_string = readTime defaultTimeLocale "%Y-%m-%d" todays_date::Data.Time.Day let todays_day = formatTime defaultTimeLocale "%a" time_from_string let todays_day_num = fromJust $ Data.Map.lookup todays_day days_map let future_day_num = fromJust $ Data.Map.lookup future_day days_map let days_to_add | future_day_num >= todays_day_num = future_day_num - todays_day_num | otherwise = (7 + future_day_num) - todays_day_num show (addDays days_to_add $ read todays_date::Data.Time.Day) readnetrc = do home <- getHomeDirectory netrc <- lines Control.Applicative.<$> readFile (home ++ "/.netrc") let netrc' = dropWhile (not . ("teuxdeux" `isInfixOf`)) netrc let (username, password) = if "login" `isInfixOf` head netrc' -- if entry is on one line |
︙ | ︙ |