Fix a function which calculates contrasting color for clock

[#44747995]

Use simpler algorithm provided by W3. Also, d3.rgb was failing
from time to time, as we use rgba strings sometimes.