Current time
edit- Simple versions
- Los Angeles: 18:16
- Denver: 19:16
- Chicago: 20:16
- New York: 21:16
- Production versions
Fractional time zones
editTry this: {{hour12|{{mod 24|{{add2|{{current hour}}|{{{1}}}}}}}}}:{{mod 60|{{add2|{{current minute}}|{{{2}}}}}}} {{AMPM|{{mod 24|{{add2|{{current hour}}|{{{1}}}}}}}}} TimBentley 04:49, 25 March 2006 (UTC)
- I just updated it, but I can't check it now (I checked some, which work), so feel free to revert if it messed stuff up. TimBentley 18:01, 25 March 2006 (UTC)
- It screwed up when the minutes were zero, I'll fix it later. TimBentley 18:03, 25 March 2006 (UTC)
- I changed Template:mod 60; this should work now. TimBentley 21:43, 25 March 2006 (UTC)
Why 12 hour clock?
editWhy does this template use a 12-hour clock instead of the standard 24-hour clock of UTC, ISO 8601 and {{CURRENTTIME}}? That would be easier and more consistent. Kusma (討論) 01:40, 30 March 2006 (UTC)
- Probably because an American made it. I'll look into changing it. TimBentley (talk) 14:58, 30 March 2006 (UTC)
Two-digit minute
editWe need to find a way to make EXPR return a two-digit minute. Times like 10:8 just confuse me. It should be 10:08 right?
I created {{two digit}} to fix this. Please wait till 15:00 (UTC) and then test it. --Uncle Ed 14:17, 14 April 2006 (UTC)
I got {{#expr: ({{current hour}} + {{{1|0}}} + (({{current minute}} + {{{2|0}}} - 30) / 60 round 0)) mod 24}}:{{two digit|{{#expr: ({{current minute}} + {{{2|0}}}) mod 60}}|}} from it, using the subst: prefix with {{utc}} just now. I guess it's okay, then. --Uncle Ed 16:03, 14 April 2006 (UTC)
- Looks awesome Ed. Pcb21 Pete 10:45, 16 April 2006 (UTC)
Mod 24 buggy for negative numbers, plus workaround
editThe following expression {{#expr: -5 mod 24}} should equal 19 but at the time of writing actually equals -5. (If that says 19 rather than -5 by the time you're reading this I am going to look silly but it did honest!). This is problematic for occasions where UTC is say 6am and you want the time in Los Angeles to read 23:00 by doing {{utc|-7}}. To avoid having to do ugly workarounds like writing 17 rather -7 as the template argument, I am going to add 24 to the current hour in this template. Pcb21 Pete 10:45, 16 April 2006 (UTC)
- The patch has now been applied and works. Pcb21 Pete 10:56, 16 April 2006 (UTC)
- You sure? AFAIK: -5 mod 24 is -5. See Modulo operation. —Locke Cole • t • c 10:55, 16 April 2006 (UTC)
- Well if there are two different conventions (and I certainly grew up with the way I mentioned), then the +24 will have to be permanent. I don't think readers will take too kindly to 9pm being written as -3! Pcb21 Pete 10:58, 16 April 2006 (UTC)
- No.. Windows Calculator (using the Scientific view; the Standard view doesn't have a "MOD") returns -5, and a brief console app written in Pascal consisting of the following:
{$APPTYPE CONSOLE} program modtest; begin WriteLn(-5 mod 24); end.
- Also says -5 on output. The implementation here is correct, however you seem to have fixed it with the +24. =) So no worries if it works, right? —Locke Cole • t • c 11:46, 16 April 2006 (UTC)
- Indeed no worries at all, this template is now quite usable IMO. Interesting though. What mathematicians do (see Modular arithmetic) is not the same as what computers do as you rightly corrected me. I'll know that for next time. Pcb21 Pete 12:10, 16 April 2006 (UTC)
Using this template on "many pages"
editOne reason why it is awkward to use this template on many pages is that you have to change every page individually when there is a daylight savings change. I have devised a template that calls this one, but minimizes the number of pages that need to be changed when there is a daylight savings change (e.g. Western Europe all change their clocks on the same day, so we only need to change one page to keep western European pages up-to-date. Please check out {{CurrentTimeIn}} (or {{CurrentTimeInHeader}} for a template that takes care of positioning too) and give me feedback. Pcb21 Pete 10:56, 16 April 2006 (UTC)
Blink
editI removed the blink formatting, it affected:
"{{User:Ed Poor/before|3|26|time is {{utc|-5}} in ny|time is {{utc|-4}} in ny}}" → "time is 21:16 in ny"; should say "time is 21:16 in ny".
Minus
editWhy must I see "UTC-5" where it should say "UTC − 5" (with a minus sign instead of a hyphen, preceded and followed by proper spaces, per Wikipedia:Manual of Style (mathematics))? Michael Hardy (talk) 06:02, 2 February 2009 (UTC)