<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0" xmlns:grazr="http://docs.grazr.com/script/spec/1.0">
<head>
  <title>APOD browser</title>
</head>
<body>
  <grazr:form name="apod">
  How many days of APOD do you want to browse?
  <input type="text" name="days" />
  </grazr:form>
  <grazr:template name="apod">
  <grazr:script><!--
    var d = new Date();
    var m = d.getTime();

    var delt = 24 * 60 * 60 * 1000;
    outline.writeText("Astronomy picture of the day browser");
    for(var i=0; i<days; i++) {    
        d = new Date(m-(delt * i));    
        //d = new Date(m);    
        var mydate = ""+d.getDate();
	mydate = mydate.replace(/^(\d{1,1})$/,"0$1");

	var myyear = ""+d.getFullYear();
	myyear = myyear.match(/\d{2,2}$/);

	var mymonth = ""+(d.getMonth()+1);
	mymonth = mymonth.replace(/^(\d{1,1})$/,"0$1");

        outline.writeLink(mymonth+"-"+mydate+"-"+myyear,"http://antwrp.gsfc.nasa.gov/apod/ap"+myyear+mymonth+mydate+".html");
	}
  --></grazr:script>
  </grazr:template>
 
  <grazr:formresult text="APOD" name="apod" />

</body>
</opml>

