Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amaurycatelan/bf56120e7159687c759ca5b6cb7b931c to your computer and use it in GitHub Desktop.
Save amaurycatelan/bf56120e7159687c759ca5b6cb7b931c to your computer and use it in GitHub Desktop.
Water Version 3
#Basic equasion, I do it this way to increase reliablity because I trust JavaScript's date parsing more than writing a regex against nightbot.
$(eval Math.trunc((Date.now()- Date.parse('$(twitch mellana "{{uptimeAt}}")'))/(1000*60*60));)
#Version 1, repeats the math multiple times
@mellana You've been live for just over $(eval Math.trunc((Date.now()- Date.parse('$(twitch mellana "{{uptimeAt}}")'))/(1000*60*60));) hours. By this point in your broadcast you should have consumed at least $(eval 4*Math.trunc((Date.now()- Date.parse('$(twitch mellana "{{uptimeAt}}")'))/(1000*60*60));)oz ($(eval 120*Math.trunc((Date.now()- Date.parse('$(twitch mellana "{{uptimeAt}}")'))/(1000*60*60));)mL) of water to maintain optimum hydration.
#Version 2, builds string in Javascript, but only does math once!
$(eval const hours = Math.trunc((Date.now()- Date.parse('$(twitch mellana "{{uptimeAt}}")'))/(1000*60*60)); "@mellana You've been live for just over " + hours + " hours. By this point in your broadcast you should have consumed at least " + (4*hours) + "oz \(" + (120*hours) + "mL\) of water to maintain optimum hydration.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment