Clock

1 - 12AM displays as 0AM when using 12 hour clock

This should fix the 0 o'clock AM issue.  You can probably come up with a more elegant solution, but this one works...

Replace:

LabelSetText("ClockWindowText", wstring.format(fmt, Clock.hour % ClockSettings.Hours Clock.min Clock.sec
LabelSetTextColor("ClockWindowText", ClockSettings.R, ClockSettings.G, ClockSettings.B)

With:

local TIMEVAR
TIMEVAR = (Clock.hour % ClockSettings.Hours
if ClockSettings.Hours == 12 then
     if TIMEVAR == 0 then
          TIMEVAR = 12
     end
end
    
LabelSetText("ClockWindowText", wstring.format(fmt, TIMEVAR, Clock.min Clock.sec
LabelSetTextColor("ClockWindowText", ClockSettings.R, ClockSettings.G, ClockSettings.B)

User When Change
mimicvii Sun, 12 Oct 2008 16:10:27 Create

You must login to post a comment. Don't have an account? Register to get one!

  • 2 comments
  • Avatar of Kravius Kravius Sun, 12 Oct 2008 23:14:20

    To make Aiiane's life a little easier, here's the cleaned up version of your code. I shot her an e-mail a few days ago with code very similar but it didn't occur to me to create a ticket for it.

    Aiiane Replace line 75 with the following code:
    <<code>> local TIMEVAR = Clock.hour % ClockSettings.Hours if TIMEVAR == 0 and ClockSettings.Hours == 12 then TIMEVAR = 12 end

    LabelSetText("ClockWindowText", wstring.format(fmt, TIMEVAR, Clock.min, Clock.sec)) <</code>>

    I'm going to add a copy of the code to the comments for the mod so that the other users can apply the fix while they wait for a new version.

  • Avatar of mimicvii mimicvii Sun, 12 Oct 2008 16:14:07

    Bah, the wiki is messing up the code, lets try this again...

    Replace the above with:

    local TIMEVAR
    TIMEVAR = (Clock.hour % ClockSettings.Hours)
    if ClockSettings.Hours == 12 then
    if TIMEVAR == 0 then
    TIMEVAR = 12
    end
    end

    LabelSetText("ClockWindowText", wstring.format(fmt, TIMEVAR, Clock.min, Clock.sec))
    LabelSetTextColor("ClockWindowText", ClockSettings.R, ClockSettings.G, ClockSettings.B)

  • 2 comments

Facts

Last updated on
13 Oct 2008
Reported on
12 Oct 2008
Status
New - Issue has not had initial review yet.
Type
Patch - Source code patch for review
Priority
Medium - Normal priority.

Reported by

Possible assignees

Votes (Total: +3, Average: +3.0)