Dialog Clock 12h or 24h

By Scakk on Mar 06, 2008

This little dialog is a clock that is the same time as the clock on your computer. It has 12 hour and 24 hour options. The title of the dialog will be the current date. The dialog will also reset at midnight so the title will change to the correct day.

The first time you open the dialog it will be on the 12 hour time. If you choose the 24 hour time it will set a variable and then if you close and reopen the dialog it will open and be on the 24 hour time setting. Same goes if you choose the 12 hour setting.

Image

http://i22.photobucket.com/albums/b328/scakk/ClockDialog.jpg <-- 24 hour version

Update: Changed the 12h to 1 "h" instead of 2 "h". Change the 24h to be without the AM/PM part. Added " $chr(32) $+ $chr(32) $+ " to the title line to make the date centered on the dialog title.

menu channel { 
  Clock: clock 
}
dialog clock {
  title Clock
  size -1 -1 165 30
  edit "", 1, 40 6 85 20, read flat center
  button "12H", 2, 5 5 30 22
  button "24H", 3, 130 5 30 22
}
on *:dialog:clock:*:*: { 
  if ($devent == init) { 
    dialog -t clock $chr(32) $+ $chr(32) $+ $date(ddd mmm doo 'yy)
    $iif((%clocktime24), clock.update2, clock.update1)
    $iif((%clocktime24), .timertcd2 0 1 clock.update2, .timertcd1 0 1 clock.update1) 
  }
  if ($devent == close) { .timerclock off | .timertcd* off }
  if ($devent == sclick) { 
    if ($did == 2) { .timertcd2 off | .timertcd1 0 1 clock.update1 | set %clocktime12 on | unset %clocktime24 }
    if ($did == 3) { .timertcd1 off | .timertcd2 0 1 clock.update2 | set %clocktime24 on | unset %clocktime12 }
  }
}
alias clock.update1 { did -ra clock 1 $time(h:nn:ss TT) | dialog -t clock $chr(32) $+ $chr(32) $+ $date(ddd mmm doo 'yy) }
alias clock.update2 { did -ra clock 1 $time(HH:nn:ss) | dialog -t clock $chr(32) $+ $chr(32) $+ $date(ddd mmm doo 'yy) }
alias clock { dialog $iif($dialog(clock), -va, -m) clock clock  }

Comments

Sign in to comment.
napa182   -  Mar 06, 2008

Id have to concur with SnoooP
SnoooP said:> not outstanding but perfect at what it does
6/10

 Respond  
SnoooP   -  Mar 06, 2008

on the ratings 4/10 is mediocre... i disagree with that its a useful snippet works and i like it... 6/10 not outstanding but perfect at what it does

 Respond  
Scakk   -  Mar 06, 2008

If you are going to rate a snippet a 4 or less then please say why you gave it that and what you feel could be added to improve it.

 Respond  
Logan   -  Mar 06, 2008

Nice Clock. I\'d give it a 4/10.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.