google.load("feeds", "1");

function initialize() {
	var mynow = new Date();
	var q = mynow.getMonth(); //月を取得
	var q2 = mynow.getDate(); //日にちを取得
	var q3 = mynow.getHours(); //時間を取得
	var query = q+"0"+q2+"0"+q3; //月日時間
	var feedurl = new Array("http://news.zigexn.co.jp/?feed=rss2"+"&"+query);

	var feed = new google.feeds.Feed(feedurl);
  feed.setNumEntries(5);
  feed.load(dispfeed);

  function dispfeed(result){
    if (!result.error){
      var container = document.getElementById("feed");
      var htmlstr = "";
        htmlstr += '<dl>';
      for (var i = 0; i < result.feed.entries.length; i++) {
        var entry = result.feed.entries[i];
        var strdate = createDateString(entry.publishedDate);
        htmlstr += '<dt>[&nbsp;';
        htmlstr += strdate;
				htmlstr += "&nbsp;]</dt>";
				htmlstr += "<dd>";
        htmlstr += '<a href="' + entry.link + '">' + entry.title + '</a>';
        htmlstr += "</dd>";
      }
				htmlstr += "</dl>";
				container.innerHTML = htmlstr;
    }else{
				alert(result.error.code + ":" + result.error.message);
    }
  }
}

function createDateString(publishedDate){
  var pdate = new Date(publishedDate);
	var pyear = pdate.getFullYear();
  var pmonth = pdate.getMonth() + 1;
	if (pmonth < 10) {pmonth = "0" + pmonth;}
  var pday = pdate.getDate();
	if (pday < 10) {pday = "0" + pday;}
  var phour = pdate.getHours();
  var pminute = pdate.getMinutes();
  var strdate = pyear + "." + pmonth + "." + pday;
//2009/01/30,
  return strdate;
}

google.setOnLoadCallback(initialize);

