Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 201

JavaScript (ES6), 201

#JavaScript (ES6), 201

JavaScript (ES6), 201

added 158 characters in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90
t=>(T=h=>String.fromCodePoint(128336+h%12),[h,m,s]=t.match(/\d+/g),'It is currently '+T(h-=~10)+((m-=-!!-s?++m:m)?` with ${60-m?60-m+' minutes'+(-s?' and ':''):''}${-s?60-s+' seconds':''} until `+T(-~h):''))
t=>(
  T=h=>String.fromCodePoint(128336+h%12),
  [h,m,s]=t.match(/\d+/g),
  'It is currently '+T(h-=~10)
   +( 
      // if seconds is not 0, increment m else just convert to number
      // have to use '- -' to force conversion to number 
     (m -= - !!-s) 
-s?++m:m)
      ? ` with ${60-m ? 60-m+' minutes'+(-s?' and ':''):''}${-s?60-s+' seconds':''} until `+T(-~h)
      : ''
    )
)
F=
t=>(T=h=>String.fromCodePoint(128336+h%12),[h,m,s]=t.match(/\d+/g),'It is currently '+T(h-=~10)+((m-=-!!-s?++m:m)?` with ${60-m?60-m+' minutes'+(-s?' and ':''):''}${-s?60-s+' seconds':''} until `+T(-~h):'')
)


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,30005000)
  }
  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?(m=0,++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, 1000)
  }
}

update()
#O { font-size:16px }
Time <input id=I value='12' oninput='update()' onkeydown='update()'>
(modify current time as you wish - but use valid values)
<pre id=O></pre>
t=>(T=h=>String.fromCodePoint(128336+h%12),[h,m,s]=t.match(/\d+/g),'It is currently '+T(h-=~10)+((-s?++m:m)?` with ${60-m?60-m+' minutes'+(-s?' and ':''):''}${-s?60-s+' seconds':''} until `+T(-~h):''))
t=>(
  T=h=>String.fromCodePoint(128336+h%12),
  [h,m,s]=t.match(/\d+/g),
  'It is currently '+T(h-=~10)
   +(
     (-s?++m:m)
      ? ` with ${60-m ? 60-m+' minutes'+(-s?' and ':''):''}${-s?60-s+' seconds':''} until `+T(-~h)
      : ''
    )
)
F=
t=>(T=h=>String.fromCodePoint(128336+h%12),[h,m,s]=t.match(/\d+/g),'It is currently '+T(h-=~10)+((-s?++m:m)?` with ${60-m?60-m+' minutes'+(-s?' and ':''):''}${-s?60-s+' seconds':''} until `+T(-~h):'')
)


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?(m=0,++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, 1000)
  }
}

update()
#O { font-size:16px }
Time <input id=I value='12' oninput='update()' onkeydown='update()'>
(modify current time as you wish - but use valid values)
<pre id=O></pre>
t=>(T=h=>String.fromCodePoint(128336+h%12),[h,m,s]=t.match(/\d+/g),'It is currently '+T(h-=~10)+((m-=-!!-s)?` with ${60-m?60-m+' minutes'+(-s?' and ':''):''}${-s?60-s+' seconds':''} until `+T(-~h):''))
t=>(
  T=h=>String.fromCodePoint(128336+h%12),
  [h,m,s]=t.match(/\d+/g),
  'It is currently '+T(h-=~10)
   +( 
      // if seconds is not 0, increment m else just convert to number
      // have to use '- -' to force conversion to number 
     (m -= - !!-s) 
-s?++m:m)
      ? ` with ${60-m ? 60-m+' minutes'+(-s?' and ':''):''}${-s?60-s+' seconds':''} until `+T(-~h)
      : ''
    )
)
F=
t=>(T=h=>String.fromCodePoint(128336+h%12),[h,m,s]=t.match(/\d+/g),'It is currently '+T(h-=~10)+((m-=-!!-s)?` with ${60-m?60-m+' minutes'+(-s?' and ':''):''}${-s?60-s+' seconds':''} until `+T(-~h):'')
)


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,5000)
  }
  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?(m=0,++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, 1000)
  }
}

update()
#O { font-size:16px }
Time <input id=I value='12' oninput='update()' onkeydown='update()'>
(modify current time as you wish - but use valid values)
<pre id=O></pre>
added 48 characters in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6), 203201

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


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?(m=0,++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, 1000)
  }
}

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

#JavaScript (ES6), 203

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


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?(m=0,++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, 1000)
  }
}

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

#JavaScript (ES6), 201

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


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?(m=0,++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, 1000)
  }
}

update()
#O { font-size:16px }
Time <input id=I value='12' oninput='update()' onkeydown='update()'>
(modify current time as you wish - but use valid values)
<pre id=O></pre>
Post Undeleted by edc65
added 48 characters in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90
Loading
added 48 characters in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90
Loading
Post Deleted by edc65
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90
Loading