Hey, what time is it? Challenge

Given a number width, number height, hours and minutes print the time using the following format style:

------  -  ------  ------  -    -  ------  ------  ------  ------  ------
|    |  |       |       |  |    |  |       |            |  |    |  |    |
|    |  |  ------  ------  ------  ------  ------       |  ------  ------
|    |  |  |            |       |       |  |    |       |  |    |       |
|    |  |  |            |       |       |  |    |       |  |    |       |
------  -  ------  ------       -  ------  ------       -  ------  ------


For numbers with a mid line, when the height is odd just place it in the middle (example for height = 3):

------
|    |
------
|    |
------


However, when the height is even you can choose up or down:

------  ------
|    |  |    |
|    |  ------
------  |    |
|    |  |    |
------  ------


Of course, you need to specify this and use it every time.



Input


W: The width of each number
H: The height of each number
HRS: Time hours
MINS: Time minutes




Output

You can either print the time, return a string (including the newlines) or return a list of strings (one string per line).



Rules


Assume number width &gt; 2
Assume number height &gt; 2
The space between numbers is fixed to 2
The space between hours and minutes is fixed to 4
If hours or minutes are &lt; 10 (single digit), make sure to add a 0 (see example)
Assume that input hours and minutes will always be valid time
Digit 1 is a special case which always has the same width 1 and only it's height changes.
Height is considered the inner height, excluding the upper and lower rows of --- (see example)




Example

Here's an example for W=6, H=4, hrs=2, mins=18:

------  ------    -  ------
|    |       |    |  |    |
|    |  ------    |  ------
|    |  |         |  |    |
|    |  |         |  |    |
------  ------    -  ------
JavaScript (ES8), 258 245 242 239 bytes

(w,h,H,M)=&gt;[2,h-1,2,h,2].map((r,y)=&gt;`${(g=x=&gt;((k=[876,,1284,260,8461,276,788,8484,780,268][x%10|0])?(s=x=&gt;' -|'[[21,8,5,10,4,2][k*2&gt;&gt;y*3&amp;7]&gt;&gt;x&amp;3])().padEnd(w-2,s(4))+s(2):'-|||-'[y])+'  ')(H/10)+g(H)}  ${g(M/10)+g(M)}
`.repeat(r/2)).join``


Try it online!

Character encoding

Digits are made of 3 distinct characters:


0: space
1: -
2: |


Pattern encoding

Each digit is made of 5 patterns:

0:  -----  &lt;-- top pattern
1:  |   |  &lt;-- upper side repeated pattern
2:  -----  &lt;-- middle pattern
3:      |  &lt;-- lower side repeated pattern
4:  -----  &lt;-- bottom pattern


Each pattern is made of a leading character \$L\$, followed by a repeated middle character \$R\$, followed by a trailing character \$T\$.

All digits can be built by using only 6 distinct patterns, which are encoded as:

$$L+R\times16+T\times4$$

 ID | Leading | Repeated | Trailing | Codes | Encoded as
----+---------+----------+----------+-------+------------
  0 |   "-"   |   "-"    |   "-"    | 1,1,1 |    21
  1 |   " "   |   " "    |   "|"    | 0,0,2 |     8
  2 |   "-"   |   " "    |   "-"    | 1,0,1 |     5
  3 |   "|"   |   " "    |   "|"    | 2,0,2 |    10
  4 |   " "   |   " "    |   "-"    | 0,0,1 |     4
  5 |   "|"   |   " "    |   " "    | 2,0,0 |     2


Digit encoding

Because of its non-standard width, \$1\$ is a special case and is processed separately.

All other digits are encoded as:

$$\frac{1}{2}\sum\limits_{n=0}^{4}2^{3n}P_n$$

where \$P_n\$ is the \$n\$-th pattern for this digit (0-indexed, from top to bottom).

 Digit | Patterns  | Encoded as
-------+-----------+------------ 
   0   | 0,3,3,3,0 |     876
   1   |    n/a    |     n/a
   2   | 0,1,0,5,0 |    1284
   3   | 0,1,0,1,0 |     260
   4   | 2,3,0,1,4 |    8461
   5   | 0,5,0,1,0 |     276
   6   | 0,5,0,3,0 |     788
   7   | 0,1,1,1,4 |    8484
   8   | 0,3,0,3,0 |     780
   9   | 0,3,0,1,0 |     268