Skip to main content
1 of 6
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6), 202

A first try, waiting for clarification from the OP

t=>(T=h=>String.fromCodePoint(128336+h%12),[h,m,s]=(t+'::').split`:`,'It is currently '+T(h-=~10)+(-m-s?(t=' until '+T(-~h),-s&&(++m,t=` and ${60-s} seconds`+t),-m&&(t=` with ${60-m} minutes`+t),t):''))

Less golfed

t=>(
  T=h=>String.fromCodePoint(128336+h%12),
  [h,m,s]=(t+'::').split`:`,
  'It is currently '+T(h-=~10)+(-m-s?(
    t=' until '+T(-~h),
    -s&&(++m,t=` and ${60-s} seconds`+t),
    -m&&(t=` with ${60-m} minutes`+t),
    t
  ):'')
)

Test

F=
t=>(T=h=>String.fromCodePoint(128336+h%12),[h,m,s]=(t+'::').split`:`,'It is currently '+T(h-=~10)+(-m-s?(t=' until '+T(-~h),-s&&(++m,t=` and ${60-s} seconds`+t),-m&&(t=` with ${60-m} minutes`+t),t):''))

var tid=0

function getTime(t)
{
  var a=t.match(/\d+/g)
  if (a) {
    var [h,m,s]=a
    h|=0, s|=0, m|=0
    if(h>=0 & h<24 & m>=0 & m<60 & s>=0 & s<60) 
      return [h,m,s]
  }
  return null
}      

function update()
{
  clearTimeout(tid)
  var t=I.value, a=getTime(t)
  if (a) {
    O.textContent = F(t)
    tid = setTimeout(again,3000)
  }
  else {
    O.textContent = 'invalid ' + t
  }
}
function again()
{      
  var t=I.value, a=getTime(t)
  if (a) {
    var [h,m,s]=a
    ++s>59?(s=0,++m>59?++h:0):0
    h%=24
    s<10?s='0'+s:0
    m<10?m='0'+m:0
    t = h+(-m-s?':'+m+(-s?':'+s:''):'')
    I.value = t
    O.textContent=F(t)
    tid = setTimeout(again, 333)
  }
}

update()
#O { font-size:20px }
Time <input id=I value='12' oninput='update()'>
(modify current time as you wish - but use valid values)
<pre id=O></pre>

edc65
  • 32.2k
  • 3
  • 36
  • 90