> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/d/draw_a_clock.md).

# Draw a clock

```ruby
STDOUT.autoflush(true)

var (rows, cols) = `stty size`.nums...

var x = (rows/2 - 1  -> int)
var y = (cols/2 - 16 -> int)

var chars = [
                 "┌─┐  ╷╶─┐╶─┐╷ ╷┌─╴┌─╴╶─┐┌─┐┌─┐   ",
                 "│ │  │┌─┘╶─┤└─┤└─┐├─┐  │├─┤└─┤ : ",
                 "└─┘  ╵└─╴╶─┘  ╵╶─┘└─┘  ╵└─┘╶─┘   "
             ].map {|s| s.split(3) }

func position(i,j) {
    "\e[%d;%dH" % (i, j)
}

func indices {
    var t = Time.local
    "%02d:%02d:%02d" % (t.hour, t.min, t.sec) -> split(1).map{|c| c.ord - '0'.ord }
}

loop {
    print "\e[H\e[J"
    for i in ^chars {
      print position(x + i, y)
      print [chars[i][indices()]].join(' ')
    }
    print position(1, 1)
    Sys.sleep(0.1)
}
```

#### Output:

```
   ╷ ┌─╴     ╷ ╷ ┌─┐     ╶─┐ ┌─╴
   │ └─┐  :  └─┤ └─┤  :  ╶─┤ └─┐
   ╵ ╶─┘       ╵ ╶─┘     ╶─┘ ╶─┘
```
