Skip to content

Instantly share code, notes, and snippets.

@bwinton
Created October 15, 2014 19:57
Show Gist options
  • Save bwinton/2063ef4ea0fa9fb9c977 to your computer and use it in GitHub Desktop.
Save bwinton/2063ef4ea0fa9fb9c977 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var suncalc = require('suncalc');
var phase = suncalc.getMoonIllumination(new Date()).phase;
var phases = [
"πŸŒ‘",
"πŸŒ’",
"πŸŒ“",
"πŸŒ”",
"πŸŒ•",
"πŸŒ–",
"πŸŒ—",
"🌘",
"🌚",
"🌝"
];
stepPhase = function (phase) {
var rv = Math.round(phase * 8) % 8;
if (Math.random() <= 0.1 && rv === 0) {
rv = 8;
} else if (Math.random() <= 0.1 && rv === 4) {
rv = 9;
}
return rv;
}
console.log(phases[stepPhase(phase)]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment