BatBeltTime utilities for Actionscript updated

I’ve updated my BatBeltTime utility class to include a method for returning the number of days in the month – something that should really be part of the Date class if you ask me.

BatBeltTime is a utility class that I put all my time/date conversion methods in. It has pretty much everything you might need for working with time for say a video player or converting between Actionscript <–>MySQL.

Download BatBeltTime.as

/**
 * 	How many days are in this month? Returns: 28-31.
 */
public static function daysInThisMonth( month:int, fullYear:int ):int {
switch( month ) {
	case 0: { // January
		return 31;
	}
	case 1: { // February
		if( fullYear % 4 == 0 ) {
			return 29;
		} else {
			return 28;
		}
	}
	case 2: { // March
		return 31;
	}
	case 3: { // April
		return 30;
	}
	case 4: { // May
		return 31;
	}
	case 5: { // June
		return 30;
	}
	case 6: { // July
		return 31;
	}
	case 7: { // August
		return 31;
	}
	case 8: { // September
		return 30;
	}
	case 9: { // October
		return 31;
	}
	case 10: { // November
		return 30;
	}
	case 11: { // December
		return 31;
	}
	default: {
		return -1;
	}
}

BatBeltTime also tells you things like:

  • Convert numeric time to English. For example: 71 –> 1 hour and 21 minutes
  • Get the name of the day from the date.
  • Get the month name from the date.
  • Get MySQL string from date
  • Make a Date object from a MySQL date string
  • Convert an MySQL Timestamp to an Actionscript Date. Thanks to Pascal Brewing for the beautiful simplicity.
  • Convert an Actionscript Date to MySQL Timestamp.  Thanks to Pascal Brewing  for the beautiful simplicity.
  • Convert an Actionscript Date to a MySQL Date
  • Input the seconds and return a string of the form: hours:mins:secs
  • Input the seconds and return a string of the form: mins:sec
  • Input seconds and return a string of the form: hours:min

Why BatBeltTime?
In case you’re wondering I named it BatBeltTime because it’s a utility class that I hang useful methods on – like Batman hangs his cool utility tools on his belt.