{"id":195,"date":"2007-01-08T12:37:46","date_gmt":"2007-01-08T18:37:46","guid":{"rendered":"http:\/\/blog.the-erm.com\/archives\/195"},"modified":"2007-01-08T12:37:47","modified_gmt":"2007-01-08T18:37:47","slug":"my-calendar-class","status":"publish","type":"post","link":"https:\/\/blog.the-erm.com\/?p=195","title":{"rendered":"My calendar class"},"content":{"rendered":"<p>After several hours of playing with php I think I&#8217;ve finally developed a stable calendar class.<br \/>\n<!--more--><br \/>\nYou&#8217;d think that making a calendar is easily done, well it&#8217;s not.<\/p>\n<p>The biggest challenge I&#8217;ve discovered was php&#8217;s date(&#8216;W&#8217;) function.<\/p>\n<p>Sometimes it&#8217;s 53, or even 54.  So you can&#8217;t rely on that.<\/p>\n<p>In the end I figured out the best way to generate the calendar is to increment the week yourself whenever the day chances.  date(&#8216;W&#8217;) wants Monday to be the first day of the week, and most calendars I&#8217;ve dealt with have Sunday as the first day of the week.<\/p>\n<p>Oh well the code is out there, and <a href=\"http:\/\/projects.the-erm.com\/showsource.php?script_name=calender.class.php\">available<\/a><\/p>\n<p>It&#8217;s basic, and only allows 1 event per day -that&#8217;s all I needed-  You could easily change<br \/>\n<code>$this->events[\"$y\"][\"$m\"][\"$d\"] = array('desc' => $desc, 'link' => $link);<\/code><br \/>\n to<br \/>\n<code>$this->events[\"$y\"][\"$m\"][\"$d\"][] = array('desc' => $desc, 'link' => $link);<\/code><\/p>\n<p>Then add a foreach\/implode for in generate_month() depending on your needs.<\/p>\n<p>Not really exciting, but it&#8217;s there.<\/p>\n<p>Erm<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After several hours of playing with php I think I&#8217;ve finally developed a stable calendar class.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,24,25,8,1],"tags":[],"class_list":["post-195","post","type-post","status-publish","format-standard","hentry","category-insanity","category-life-stories","category-php","category-tech","category-happy"],"_links":{"self":[{"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=195"}],"version-history":[{"count":0,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/posts\/195\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}