Formatted date and times

by Laurie

HTML

<body>
    <h1>Formatted date and times</h1>
    <p>UTC: <time data-bind="{ format:'utc' }" datetime="2013-09-09T15:27:11.000+10:00"></time></p>
    <p>Full: <time data-bind="{ format:'full',titleFormat:'local' }" datetime="2013-09-09T15:27:11.000+10:00"></time></p>
    <p>ISO: <time data-bind="{ format:'iso' }" datetime="2013-09-09T15:27:11.000+10:00"></time></p>
    <p>Time: <time data-bind="{ format:'time' }" datetime="2013-09-09T15:27:11.000+10:00"></time></p>
    <p>12 hour: <time data-bind="{ format:'time12' }" datetime="2013-09-09T15:27:11.000+10:00"></time></p>
    <p>24 hour: <time data-bind="{ format:'time24' }" datetime="2013-09-09T15:27:11.000+10:00"></time></p>
</body>

CSS

p {
    font-family: 'Helvetica Neue', arial, sans-serif;
    font-size: 20px;
    color: #525252;
}

JavaScript

/**
 * @class localDateTime
 * @verson 0.4
 * @author Christopher D Langton <[email protected]>
 * @classDescription Convert Dates and Times to users local
 * @compatibility:
 *        IE 8+
 *        Firefox 4+
 *        Chrome 7+
 *        Safari 5.0.5+
 *        Opera 12+
 *        iOS Safari 4.0+
 *        Android Browser 2.1+
 *        Chrome for Android 28+
 *        Firefox for Android 23+
 *        Blackberry Browser 7.0+
 */
'use strict';
var ConvertDateTimes = function(arg,fn) {
	try{
		/**
		 * @property elements
		 * @type {Array}
		 * @access public
		 */
		this.elements = [];
		/**
		 * @property options
		 * @type {Object}
		 * @access public
		 */
		this.options = {
			format: 'local',
			enableTitle: true,
			titleFormat: 'full',
			allow: ['full','local','utc','iso','time','time12','time24']
		};
		/**
		 * @property timezoneOffset
		 * @type {Integer}
		 * @access public
		 */
		this.timezoneOffset = (new Date()).getTimezoneOffset() / 60;
		// Initialization
		if ('object' === typeof arg ){
			for (var key in arg) {
				if (arg.hasOwnProperty(key)) {
					if ( key === 'format' ) {
						this.defaultFormat(arg[key]);
					}
					if ( key === 'enableTitle' ) {
						this.enableTitle(arg[key]);
					}
					if ( key === 'titleFormat' ) {
						this.titleFormat(arg[key]);
					}
				}
			}
		} else if ('string' === typeof arg ) {
			this.defaultFormat(arg);
		}
		if ('function' === typeof arg ) {
			this.init(arg);
		} else {
			 if ('function' === typeof fn ) {
				this.init(fn);
			} else { 
				this.init();
			}
		}
	} catch (err) {
		this.errors.push({
			datetime: (new Date()).toLocaleString(),
			type: err.name,
			message: err.message
		});
		return true;
	}
};
// Instance methods
ConvertDateTimes.fn = ConvertDateTimes.prototype = {
	/**
	 * @method init
	 * @param {Function} fn Callback function
	 * @access public
	 * @return {Object} Returns ConvertDateTimes for method chaining
	 */
    init: function(fn){
		this.errors =...