Open kleinesfilmroellchen opened 6 years ago
Couldn't a word clock also be done by taking a digital clock, passing the numbers through a look up conversion and slightly restyling the display? So instead of HH:MM:SS you'd send something like F(HH)+" Hours "+F(MM)+" Minutes and "+F(SS)+" seconds"
This function basically fills in for F() and should work up to 999,999 but could easily be expanded to include millions billions etc.. with copy paste tweak of the thousand code
intToWords(i){
var res = ""
if (i>=2000) {
//numbers above two thousand tend to be said as thousands eg two thousand and one
res += intToWord(Math.Floor(i/1000) + " thousand "
i = i%1000
}
if ( i%2000 >=100){
//numbers up to two thousand tend to be said as hundreds eg nineteen hundred and ninety nine
res += intToWord(Math.Floor(i/1000)) + " hundred "
i = i%100
}
if ( i>0 ) {
//include the "and" between the bigger numbers and the tens/units
res += "and "
}
if ( i>10 && i<20 )
//special cases for eleven, twelve, ..., nineteen
} else {
if ( i !== 0 ){
if ( i >= 10 ){
//cases for ten, twenty, ..., ninety
}
if ( i%10 > 0 ){
//cases for one, two ... nine
}
} elseif ( res === "" ){
//special zero case
res += zero
}
}
return res
}
I think coding and thinking about how to convert numbers into text or vice versa could be really interesting especially since different languages have different special cases
If you looked at my example, you see that I didn't simply pretty-printed the time (piece o' cake) but rather used a function (very end of sketch) to select up to four words (there is no upper limit, German simply doesn't ever use more) depending on minute and hour and return them in an array. The main loop doesn't do more than turning all words off first and turning only the words returned by the function back on. English is, in my opinion, quite simple, as it restricts the number of possible wordings significantly. German, for example, allows constructs that literally translate to "ten to half to five" or "twenty past half to twelve" (you see, it doesn't work in English).
I don't understand german so I kind of saw what I wanted to with it displaying numbers as words in different parts of the screen, I just went back and actually it's lighting up from all the words which are always printed, I just couldn't easily see them on my monitor.
I'm guessing my way is just one other way of doing a clock with words and would probably work better for what the americans call military time.
But I think my final point actually stands "I think coding and thinking about how to convert numbers into text or vice versa could be really interesting especially since different languages have different special cases" because in english we would never say "ten to half to" anything.
For time scales at five minute increments in that way I guess we'd go with these 12 things which would be different to code from both my code above and you example, "HOUR O'Clock" "Five Past HOUR" "Ten Past HOUR" "Quarter Past Hour" "Twenty Past HOUR" "Twenty Five Past HOUR" "Half Past HOUR" "Twenty Five to HOUR" "Twenty to HOUR" "Quarter to HOUR" "Ten to HOUR" and "Five to HOUR".
Where as when I say a time between the hours I tend to say something like "it's nineteen forty eight" and not need to clarify what's hours or minutes, and on the hour use the O'Clock convention rather than saying hundred like military time, which is a lot closer to what I posted above and why I suggested it as one additional way that a word clock could be made.
You are basically right with your middle part, what I am displaying is the German equivalent of things like "quarter to six" or "ten past eleven" (my translation was literal and I am aware that is is NOT allowed in English). I sorta had bad design there because the "off" words have a greyscale of 10 (see textobject.js for details on display) which was fine on my crappy laptop LCD monitor, but not on phones or other better screens (just checked on my phone, it is not easy to see). I will go back this afternoon and make an English version so that it is easier to understand for everyone. Your suggestion is actually better than my current version, because you suggest five-minute timesteps and I sometimes use five-minute timesteps, sometimes ten-minute timesteps. Thank you for your suggestions, I think we had a small misunderstanding issue there.
^_^ you're welcome
Also I wasn't saying yours was wrong or bad, it just wouldn't work so well for me, not least because it was in German but rather clocks are like that, some people find some clocks easier to read than others, some people can look at hands of an analogue clock and see the time without numbers, others need the numbers some even need the minutes conversion around the edge, some prefer digital or binary or dozenal clocks, there are people who need speaking clocks and those that enjoy clocks that run on marbles or water in terms of physical time pieces there are already hundreds probably thousands of designs that to some don't look like clocks at all while others can read with no problem there are clocks that transcend culture, in basic form like the analogue clock, and there are some that're so esoteric they basically need a training course to comprehend as instinctively like the long now clock which plays a slow ever changing subtle melody that won't repeat for 10,000 years.
The purpose of my first suggestion was mainly to express my enthusiasm (though I seem to have cut that in the preference of brevity looking back) and then explain my train of coding thought on how else someone might go about this maybe something more along the lines of "hey this would be cool as a coding challenge even if it's not exactly cloning something you made, everyone's different and showing (inspiring people with) how to code their perfect word clock would be awesome and as an aside this awesome ints to natural language thing I just thought of dropped out of my thinking about how I'd want to code this for me, I realise someone's probably already done something similar but I think it's cool enough to share too" wouldn't have come across so aggressively.
;) it's better and usually more helpful to ascribe incompetence (usually in communicating) to things that seem malicious ;)
sorry for responding so much later...
thank you very much. I would love to see p5 implementations of the clock types you suggested! As you might have guessed, I never came around to implementing the English version of my exact clock, and that is not on my current coding project schedule.
This might be considered similar to the analog clock coding challenge, but it's a totally different type of clock: a clock completely made out of words. It is actually inspired by a real-world clock I saw a couple months back.
I have made a clock with German time description in p5.js (and a bit HTML/CSS), take a look: https://rawgit.com/kleinesfilmroellchen/Wordclock/master/index.html The source and a short explanation can be found at https://github.com/kleinesfilmroellchen/Wordclock
Although my implementation seems overcomplicated, it's just for scalability's sake (and to later modify easily). I am pretty sure it can be done without a lot of long-winded, cryptic code (sorry). Hope this will be a coding challenge one day!
kleinesfilmröllchen