vm/src/lib.js
function (table) {
			var time;
			
			if (!table) {
				time = Date['now']? Date['now']() : new Date().getTime();
				
			} else {
				var day, month, year, hour, min, sec;
				
				if (!(day = table.getMember('day'))) throw new shine.Error("Field 'day' missing in date table");
				if (!(month = table.getMember('month'))) throw new shine.Error("Field 'month' missing in date table");
				if (!(year = table.getMember('year'))) throw new shine.Error("Field 'year' missing in date table");
				hour = table.getMember('hour') || 12;
				min = table.getMember('min') || 0;
				sec = table.getMember('sec') || 0;
				
				if (table.getMember('isdst')) hour--;
				time = new Date(year, month - 1, day, hour, min, sec).getTime();
			}
			
			return Math.floor(time / 1000);
		}
function (table) {
			var time;
			
			if (!table) {
				time = Date['now']? Date['now']() : new Date().getTime();
				
			} else {
				var day, month, year, hour, min, sec;
				
				if (!(day = table.getMember('day'))) throw new shine.Error("Field 'day' missing in date table");
				if (!(month = table.getMember('month'))) throw new shine.Error("Field 'month' missing in date table");
				if (!(year = table.getMember('year'))) throw new shine.Error("Field 'year' missing in date table");
				hour = table.getMember('hour') || 12;
				min = table.getMember('min') || 0;
				sec = table.getMember('sec') || 0;
				
				if (table.getMember('isdst')) hour--;
				time = new Date(year, month - 1, day, hour, min, sec).getTime();
			}
			
			return Math.floor(time / 1000);
		}
function ( table ) { var time ; if ( ! table ) { time = Date [ 'now' ] ? Date [ 'now' ] ( ) : new Date ( ) . getTime ( ) ; } else { var day , month , year , hour , min , sec ; if ( ! ( day = table . getMember ( 'day' ) ) ) throw new shine . Error ( "Field 'day' missing in date table" ) ; if ( ! ( month = table . getMember ( 'month' ) ) ) throw new shine . Error ( "Field 'month' missing in date table" ) ; if ( ! ( year = table . getMember ( 'year' ) ) ) throw new shine . Error ( "Field 'year' missing in date table" ) ; hour = table . getMember ( 'hour' ) || 12 ; min = table . getMember ( 'min' ) || 0 ; sec = table . getMember ( 'sec' ) || 0 ; if ( table . getMember ( 'isdst' ) ) hour -- ; time = new Date ( year , month - 1 , day , hour , min , sec ) . getTime ( ) ; } return Math . floor ( time / 1000 ) ; }
Implementation of Lua's os.time function.
@param {object} table The table that will receive the metatable.
Implementation of Lua s os . time function .