FuzzyTime

EDIT: looking for anyone wishing to help me with translations (no programming knowledge required)
EDIT:
(v0.6+) now with timer mode:
Example use: Say you have fuzzytime piped to your status bar and it serves as a usual clock applet. Then you got an e-mail saying that you're going to have a meeting at one o'clock. You set the timer to 13:00 and instead of the current time, fuzzytime begins to show you how much time you have left till the meeting. After you come back, you unset the timer and have fuzzytime display the current time again.
Hello
The now-not-so-recent upgrade to Python 3 broke fuzzyclock which I liked a lot. Since my Python is next to non-existent, I decided to use the opportunity to dust off the little Haskell I knew, so here goes:
A clock and timer that tell the time in a more human way.
v0.7.6, 2011.12.30, *antispam*, GPL3+
fuzzytime [COMMAND] ... [OPTIONS]
Common flags:
-? --help Display help message
-V --version Print version information
fuzzytime clock [OPTIONS]
Print fuzzy time if timer is not set, and countdown if it is.
-a --caps=INT Capital letters; default 1 (see the man page).
-c --clock=INT 12 or 24-hour clock; default 12-hour.
-l --lang=ITEM Language (currently da, de, el, en, es, fr, it, ja, nb,
nl, pl, se and tr); default en.
-p --prec=INT Precision (1 <= prec <= 60 [minutes]); default 5.
-t --time=ITEM Time to fuzzify as HH:MM; default current time.
-o --sound=ITEM Command to play the alarm sound; see man for the default.
-s --style=INT How the time is told (see the man page); default 1.
fuzzytime timer [OPTIONS] [END]
Set timer to END as HH:MM or "unset". (Disables printing time.)
You can get the source from here. It requires runhaskell (e.g. ghc) and haskell-cmdargs. An AUR package is here. [edit: added aur link]
WARNING: it's not properly tested so if you're late for anything, don't blame me. You can tell me, though, and make me feel guilty if you like.
If you find any bugs, please let me know.
Currently, only two languages are supported: English and Polish. If you're willing to add another one or would just like to have another one but don't know how to or don't feel like doing it, please contact me.
Happy timing
EDIT:
v0.7.6 (2011.12.30)
-- added Japanese (by Jens Petersen)
v0.7.5 (2011.11.28)
-- added alarm sound config
v0.7.4 (2011.04.26)
-- added Italian (thanks erm67)
v0.7.3 (2011.04.22)
-- added Swedish (thanks Closey)
v0.7.2 (2011.04.17)
-- added --caps (0: all lowercase; 1: default; 2: Title Case; 3: ALL CAPS)
v0.7 (2011.01.24)
-- added Norwegian (thanks arnvidr)
-- added timer for Dutch (thanks Boris27) and German (thanks marens and ichbinsisyphos)
-- added Danish style 2
-- added German style 3 (thanks marens and ichbinsisyphos)
-- added Spanish style 3 (thanks xenofungus)
-- added timer alarm sound
-- fixed exit codes
v0.6 (2011.01.21)
-- added the timer mode (en, fr, pl and tr)
-- added Spanish (thanks itsbrad212)
-- fixed the almost-next-hour bug
v0.5 (2011.01.17)
-- added halves as base (de, nl and pl)
-- added Greek (thanks Gbak), Dutch (thanks litemotiv) and Turkish
-- some corrections (thanks D. Fischer from [email protected] again)
v0.4.1 (2011.01.15)
-- fixed nextFTHour
v0.4 (2011.01.15):
-- added --time (thanks D. Fischer and B. Yorgey from [email protected])
-- added --style
-- added Danish (by M_ller with my modifications)
-- removed "poĊ‚udnie" from pl
-- sorted out the representation of midnight and noon
-- added a man page
v0.3 (2011.01.14):
-- added midnight and noon
-- added checking cli options
-- fixed the "quarter part quarter" bug
v0.2 (2011.01.12):
-- added French and German
-- added 12 vs. 24-hour clock
Last edited by caminoix (2011-12-30 22:05:00)

caminoix wrote:
M_ller wrote:I could help you out translating it to Danish if you want.
Wonderful!
I suppose what I'm going to need is:
1. the desired casual "names" for the following hours: 23:30, 23:45, 00:00, 00:15, 11:30, 11:45, 12:00, 12:15, 22:00, 22:10, 22:15, 22:25, 22:30, 22:35, 22:45, unless there are any other "special" hours in Danish, i.e. ones that would not get properly rendered by an algorithm covering the above?
2. if possible, you to check the results once they are ready. Unfortunately, I do not know Danish and couldn't be sure when doing it myself.
Thank you for your help!
EDIT: I just realized that you might be actually wanting to implement it yourself. In such case just drop me a line whenever you're not sure why I did something the way I did, or want to bash me for my programming ignorance Unless you want to fork, I'll be very happy to incorporate your code if you agree.
I have edited your source (fuzzytime.hs) and here is the result.
showFuzzyTimeDa :: FuzzyTime -> String
showFuzzyTimeDa (FuzzyTime am clock hour _ min)
| min == 0 = if (getHour hour) `elem` ["midnat", "aften"] then (getHour hour) else (getHour hour) ++ " klokken" -- We don't really use anything. You could remove " klokken"
| min <= 30 = getMin min ++ " over " ++ getHour hour
| min > 30 = getMin (60-min) ++ " i " ++ getHour (hour+1)
| otherwise = "Ups, det ser ud til den er " ++ show hour ++ ":" ++ show min ++ "."
where
getHour :: Int -> String
getHour h
| h == 0 && am = "midnat"
| h == 0 && not am = if clock==12 then "aften" else "midnat"
| h == 12 = "aften"
| otherwise = numeralDa h
getMin :: Int -> String
getMin m
| m == 30 = "halv" -- You should note that we don't say "half past 2" when it's 14:30. We say "It's half 3".
| m `elem` [15, 45] = "kvarter"
| otherwise = numeralDa m
numeralDa :: Int -> String
numeralDa n
| n < 20 = numeralDaHelper1 n
| n `mod` 10 == 0 = numeralDaHelper10 (n `div` 10)
| otherwise = numeralDaHelper10 (n `div` 10) ++ "-" ++ numeralEnHelper1 (n `mod` 10)
where
numeralDaHelper1 :: Int -> String
numeralDaHelper1 i = ["nul", "et", "to", "tre", "fire", "fem", "seks", "syv", "otte", "ni", "ti", "eleve", "tolv", "tretten", "fjorten", "femten", "seksten", "sytten", "atten", "nitten"] !! i
numeralDaHelper10 :: Int -> String
numeralDaHelper10 i = ["tyve", "tredive", "fyrre", "halvtreds"] !! (i-2)
23:30 - Halv tolv          (perhaps fireogtyve instead of tolv)
23:45 - Kvart i tolv       (perhaps fireogtyve instead of tolv)
00:00 - Tolv                  (perhaps fireogtyve instead of tolv)
00:15 - Kvart over tolv (perhaps fireogtyve instead of tolv)
11:30 - Halv tolv
11:45 - Kvart i tolv
12:00 - Tolv
12:15 - Kvart over tolv
22:00 - Toogtyve
22:10 - Ti over toogtyve
22:15 - Kvart over toogtyve
22:25 - Femogtyve over toogtyve
22:30 - Halv treogtyve
22:35 - Femogtyve i treogtyve
22:45 - Kvart i treogtyve
It's quite confusing 'cause we usually use "tolv" for both 12:00 and 24:00 (and eleve for 11:00 and 23:00 and so on), but to be correct, you should probably stick with tolv for 12 and fireogtyve for 24.
Last edited by M_ller (2011-01-14 21:41:22)

Similar Messages

Maybe you are looking for

  • Problem with ranges

    Hi Experts, I have created 1 range RANGES : r_fname FOR cdpos-fname. I want to check that value of range name is available or not. Please give me proper example of code so i can paste and check it. I want to append it with in loop. Can we do this ? R

  • Is it possible to sort document using Description field?

    In a specific folder you can sort documents by "Name", "Size" and "Last modified" fields. does anyone know how to enable the sort by "Description"? Thanks, Nadia

  • Error with LSMW IDOC method while maintaining Quota arrangement

    Hi I am trying to create LSMW using IDOC method for maintaining quota Arrangment. I used the standard Message type LPIEQU. Idoc is getting generated and when i tried to process this IDOC i am getting error "Function module not allowed: BAPI_IDOC_INPU

  • IPad vs A P.C. Useing Facebook

    Apple Ipad 2 does not have features found on a P.C. To share, posts, or edit posts. Why ? https://www.youtube.com/watch?v=49IQ83TbojA&feature=g-crec-u

  • Is it possible to script After Effects with Visual Studio?

    It's fairly easy to do with Illustrator, but I can't seem to find any documentation about how to do it with After Effects. With Illustrator, I can simply import the ScriptingSupport.aip to Visual Studio as a reference and have full c# access. Can't s