Skip to content

Instantly share code, notes, and snippets.

@BlessYAHU
Forked from anonymous/index.html
Created March 16, 2016 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlessYAHU/5aa2ec3b88d805f3ecbb to your computer and use it in GitHub Desktop.
Save BlessYAHU/5aa2ec3b88d805f3ecbb to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/kigulex
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.83/Bacon.min.js"></script>
<style id="jsbin-css">
body {
font-size: 200px;
}
</style>
</head>
<body>
<script id="jsbin-javascript">
'use strict';
(function (global, Bc) {
var pollingInterval = 1000;
Bc.fromPoll(1000, function () {
return new Bc.Next(new Date());
}).map(function (currentDate) {
return {
hour: currentDate.getHours(),
minutes: currentMinutes = currentDate.getMinutes(),
seconds: currentDate.getSeconds()
};
}).map(function (currentTime) {
return {
hour: currentTime.hour,
minutes: (currentTime.minutes < 10 ? '0' : '') + currentTime.minutes,
seconds: (currentTime.seconds < 10 ? '0' : '') + currentTime.seconds
};
}).map(function (currentTime) {
var timeOfDay = currentTime.hour < 12 ? 'AM' : 'PM';
var convertedHour = currentTime.hour;
if (currentTime.hour > 12) convertedHour = currentTime.hour - 12;
if (currentTime.hour === 0) convertedHour = 12;
return {
hour: convertedHour,
minutes: currentTime.minutes,
seconds: currentTime.seconds,
timeOfDay: timeOfDay
};
}).map(function (currentTime) {
return currentTime.hour + ':' + currentTime.minutes + ':' + currentTime.seconds + ' ' + currentTime.timeOfDay;
}).onValue(function (displayTime) {
return global.document.querySelector('body').innerHTML = displayTime;
});
})(window, Bacon);
</script>
<script id="jsbin-source-css" type="text/css">body {
font-size: 200px;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">((global,Bc)=> {
const pollingInterval = 1000;
Bc.fromPoll(1000,()=> new Bc.Next(new Date()))
.map((currentDate)=> ({
hour: currentDate.getHours ( ),
minutes: currentMinutes = currentDate.getMinutes ( ),
seconds: currentDate.getSeconds ( )
}))
.map((currentTime)=> ({
hour : currentTime.hour,
minutes: (currentTime.minutes < 10 ? '0' : '') + currentTime.minutes,
seconds: (currentTime.seconds < 10 ? '0' : '') + currentTime.seconds
}))
.map((currentTime)=> {
const timeOfDay = currentTime.hour < 12 ? 'AM' : 'PM';
let convertedHour = currentTime.hour;
if(currentTime.hour > 12) convertedHour = currentTime.hour - 12;
if(currentTime.hour === 0 ) convertedHour = 12;
return {
hour: convertedHour,
minutes: currentTime.minutes,
seconds: currentTime.seconds,
timeOfDay: timeOfDay
};})
.map((currentTime)=> `${currentTime.hour}:${currentTime.minutes}:${currentTime.seconds} ${currentTime.timeOfDay}`)
.onValue((displayTime)=> global.document.querySelector('body').innerHTML = displayTime);
})(window,Bacon)</script></body>
</html>
body {
font-size: 200px;
}
'use strict';
(function (global, Bc) {
var pollingInterval = 1000;
Bc.fromPoll(1000, function () {
return new Bc.Next(new Date());
}).map(function (currentDate) {
return {
hour: currentDate.getHours(),
minutes: currentMinutes = currentDate.getMinutes(),
seconds: currentDate.getSeconds()
};
}).map(function (currentTime) {
return {
hour: currentTime.hour,
minutes: (currentTime.minutes < 10 ? '0' : '') + currentTime.minutes,
seconds: (currentTime.seconds < 10 ? '0' : '') + currentTime.seconds
};
}).map(function (currentTime) {
var timeOfDay = currentTime.hour < 12 ? 'AM' : 'PM';
var convertedHour = currentTime.hour;
if (currentTime.hour > 12) convertedHour = currentTime.hour - 12;
if (currentTime.hour === 0) convertedHour = 12;
return {
hour: convertedHour,
minutes: currentTime.minutes,
seconds: currentTime.seconds,
timeOfDay: timeOfDay
};
}).map(function (currentTime) {
return currentTime.hour + ':' + currentTime.minutes + ':' + currentTime.seconds + ' ' + currentTime.timeOfDay;
}).onValue(function (displayTime) {
return global.document.querySelector('body').innerHTML = displayTime;
});
})(window, Bacon);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment