RDO Calender Development Update

Hello to anyone who actually reads this!

Unfortunately I don’t have the commitment to develop features at a steady pace. So enhancements wind up trickling in little by little as time goes by. Having said that, it seems that I’m currently on a spree and have been working on enhancements for RDO Calendar. Here’s some enhancements that were made recently:

  • Yearly Calendar View! This has been asked for by multiple people. There is now a link that will allow you to view the whole RDO year at once. I’m assuming it’s mostly used for printing. I’ve also optimized the print layout to fit on 2 pages if you print in landscape mode. Might have to shrink you margins a bit too.
  • Swipe right & left on mobile devices! If you’re on a smartphone you’ll no longer have to click the next/last month buttons, you can just swipe the month to go forward/back. This might work on touchscreen desktops too but I don’t have a good way of testing it.

I’ve got more features planned so stay tuned!

RDO Calendar Native Android App!

Yesterday I released the RDO Calendar android app version 2.0. https://play.google.com/store/apps/details?id=com.rdocalendar . This is the first real android app and not a web wrapper like it previously was. Although some features were skipped in favor of simplicity (holidays, pay days) I’m sure these will be added soon along with more fun stuff. Biggest gain is obviously the app now works offline. Hope you guys enjoy it!

RDO Calendar Android App!

Finally published an RDO Calendar app in the Google Play store. https://play.google.com/store/apps/details?id=com.rdocalendar Currently it’s just a simple web wrapper for the website but I’m working on a real version in the meantime. Be sure to check it out and tell your friends.

PEAR in lithium PHP

Googling for PEAR and Lithium PHP will inevitably lead you to their docs. This pretty much describes all you have to do. Just keep in mind a few things:

  1. You don’t have to use the above method. It’s only if you’d like to use the “use” keyword to load the classes. You can still easily import the files via include or require.
  2. To refer to a class you have to use the \. e.g. $cmonth = new \Calendar_Month_Weekdays($year, $month);
  3. Don’t forget to put PEAR in the libraries folder of your lithium installation. Don’t blindly follow the doc. Mine was in /usr/share/pear/ (on arch linux)

Firetray for Thunderbird 8

Since the upgrade I bet a few people are searching for a working firetray plugin for their thunderbird 8 (myself included). After a quick google search turns out there’s an upcoming version of firetray 0.4.0 that works with 8. You can download the xpi from the official google code page: http://code.google.com/p/firetray/downloads/detail?name=firetray-0.4.0a2.xpi&can=2&q=

Using cookies in Lithium PHP

RDO Calender required me to use cookies to keep track of simple session information. For a while I couldn’t figure it out but after reading the unit tests I got it.


Instead of using the $_COOKIE superglobal you can use Lithium’s Session adapter to create a cookie adapter then use inside your controllers. First start off by setting up the adapter in the configuration file.
app/config/bootstrap/session.php (make sure the session.php file is uncommented in app/config/bootstrap/bootstrap.php)

	'cookie' => array('adapter' => 'Cookie', 'expire' => '+365 day'),
	'default' => array('adapter' => 'Php')

Below are all the options, taken from libraries/lithium/storage/session/adapter/Cookie.php

	 * Default settings for this session adapter.
	 * @var array Keys are in direct correspondence with the parameters in the PHP-native
	 *      `setcookie()` method. The only difference is that the `expire` value is a
	 *		strtotime-compatible string instead of an epochal timestamp.
	protected $_defaults = array(
		'expire' => '+2 days', 'path' => '/', 'name' => null,
		'domain' => '', 'secure' => false, 'httponly' => false


After the setup is done, you can read and write cookies using the Session::read and Session:write functions respectively.

Session::read($key = null, array $options = array());
Session::write($key, $value = null, array $options = array());

It’s fairly straightforward. In options you’ll have to specify the cookie that you created. Full Session::read example below.

Session::read('cal.dow', array('name' => 'cookie'));

where ‘cookie’ is the name of the adapter we created in the config.

Lithium PHP uses the ‘.’ character to give namespaces to the cookie keys. Each key is broken into sections and restructured using ‘[‘ and ‘]’. The call above will read the cookie of key “appcookie[cal][dow]”

JQuery cookie plugin

Because I was using the jquery.cookie.js plugin in conjunction; I want to point out that the plugin (and possibly others) use encodeURIComponent() to escape keys/values when setting cookies. This escaped the ‘[]’ characters used by lithium. I modified the aforementioned plugin to accept a rawKey parameter that will prevent the key from being escaped.
relevant excerpt:

return (document.cookie = [
            options.rawKey? key : encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''

Launching rdocalendar.com

Due to recent legal matters I had to take down nypdcalendar.com. I promised to launch rdocalendar.com (Same thing, different name) but wanted to wait a bit so that I would release a better version.

Upon seeing my friend recently he reminded me that calendar services are still needed regardless of it being a new version or not. So without further ado I announce rdocalendar.com! Currently it’s the exact same thing, but to borrow a con ed slogan: “we’re on it!” Hopefully the slogan isn’t trademarked. I had enough with that as it is.

UNlaunching of nypdcalendar.com

Due to a (fairly large actually) oversight on my part; today I was contacted by Gerard Singleton, an attorney from the NYC trademark enforcement office. This post marks the UN-launching of nypdcalendar.com. The site now redirects to a nyc.gov page.

The site is gone but the spirit isn’t. I’ve registered rdocalendar.com so stay tuned for updates (trademark infringement free this time).


These past few days I’ve been working on version 2 of Vlad Tracker. Although it may be a bit premature but I’m proud to announce the launch of nypdcalendar.com. It’s basically Vlad Tracker but adjustable so can be used by other members of the force. The default is set at his schedule but can be easily changed via the link on the bottom.

My next order of things will be branding & styling. After that I think I’ll write mobile browser friendly CSS and perhaps make the whole thing a facebook app.

PHP Calendar Month Function

I decided to start working on a follow-up project to my previous Vlad Tracker. The first version of it is pretty simple. It just lists all of his days off vertically. Next step of course is to display everything in a calendar view. The first version also focused on simplicity, including all of the scripts & styles inline so that it could be just saved on the hard drive without any messy additional files. This time it is in PHP because of the convenient date manipulation functions.

I needed a function that would generate a calendar month. After a bit of searching on google, I didn’t find any code that did what I wanted. Everything already generated html with calendar-type widgets. So I wrote my own.

PHP function getCalendarArray takes 2 arguments; a date and a number representing day of the week. The date can be either a string representing a date (as accepted by DateTime object) or a DateTime object itself. The second parameter is an integer 0-6 representing the first day of the week. 0 for Sunday, 1 for Monday … 6 for Saturday. The function returns an array where each element is an array representing a date. It’s meant to fit in a square so the first and last few days will be of the previous and next month respectively. The outer array is numerically indexed, the outer array contains the following string indexes: day, month, year, specified. Specified is a boolean representing the specific date that is passed in the first argument.

Function prototype:

function getCalendarArray([$date [, $dao_adj]])

Sample abridged return value:

  0 => 
      'day' => int 28
      'month' => int 8
      'year' => int 2011
      'specified' => boolean false
  1 => 
      'day' => int 29
      'month' => int 8
      'year' => int 2011
      'specified' => boolean false
  2 => 
      'day' => int 30
      'month' => int 8
      'year' => int 2011
      'specified' => boolean false
  3 => 
      'day' => int 31
      'month' => int 8
      'year' => int 2011
      'specified' => boolean false
  4 => 
      'day' => int 1
      'month' => int 9
      'year' => int 2011
      'specified' => boolean false
  5 => 
      'day' => int 2
      'month' => int 9
      'year' => int 2011
      'specified' => boolean false
  6 => 
      'day' => int 3
      'month' => int 9
      'year' => int 2011
      'specified' => boolean false

Basically this functions provides data on how to render the calendar but doesn’t have any of the rendering code. Making it perfect for integration into custom calendar projects. Feel free to use it however you want!

View the full source, with comments and license.