The bond counter: Peanut version
Monday, July 25th, 2005Inspired by the whole NKF saga and mrbrown’s very amusing last entry in SNE108, I’ve rewritten the bond countdown timer to give the amount payable in peanuts (locally defined currency, where one peanut == S$600,000).
<script type=""text/javascript">
function formatAsPeanuts(mnt) {
mnt -= 0;
mnt = (Math.round(mnt*1000000))/1000000;
return mnt;
} // modified from http://www.rgagnon.com/jsdetails/js-0076.html
/*
BOND COUNTER: PEANUT VERSION
Simple script that writes out a line of text with how many days of bond left to go, and how much it's worth right now if paid up. E.g. "1870 days and 0.82241 peanuts left to go". Extremely depressing.
Variables to change:
enddate:
The end date of the bond, assuming a full (4/6/8-year) bond.
enddate_discount:
The end date of the bond assuming it's completed. Applies only to those who serve full-time NS and have half of that counted towards the bond (usually 10 months).
startdate:
First day of work.
bond:
Bond value with interest and LD. Assumes a linear depreciation of an already-compounded bond value with liquidated damages. The amount signed on the contract can be used as a rough estimate.
OPTIONAL -- nowdate:
Change to a date in the future e.g.
nowdate = new Date("June 20, 2009");
to see how much to pay at that point of time.
*/
var enddate = new Date("June 20, 2011");
var enddate_discount = new Date("August 20, 2010");
// Uncomment this following line if end date is fixed:
// enddate_discount = enddate;
var startdate = new Date("June 20, 2005");
var bond = 500000;
bond = bond / 600000; // convert to peanuts
var nowdate = new Date();
ms1 = enddate_discount - nowdate;
days = Math.floor(ms1 / 86400000); // converts from milliseconds to days
document.write(days);
document.write(" days and ");
total = enddate - startdate;
ms2 = enddate - nowdate;
rem = formatAsPeanuts(ms2 / total * bond);
document.write(rem);
document.write(" peanuts left to go");
</script>
Technorati Tags: peanutcurrency





