'use strict';

Object.defineProperties(this, {
	EMPTY_FUNCTION: {
		enumerable: true,
		get: function () {
			return function () { return; };
		}
	},
	GAME_TIME: {
		enumerable: true,
		get: function() {
			return new Date(Date.LocaltoHN());
		}
	},
	UTC_OFFSET: {
		enumerable: true,
		get: function() {
			return getUTCOffset();
		}
	},
	WATCH_LIST_MAX: {
		enumerable: true,
		value: 50
	},

	generateUUID: {
		enumerable: true,
		value: function () {
			var d = Date.now();

			return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function (c) {
				var r = (d + Math.random() * 16) % 16 | 0;
				d = Math.floor(d / 16);
				return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
			});
		}
	},
	getType: {
		enumerable: true,
		value: function (object) {
			return Object.prototype.toString.call(object).replace(/\[object ([^\]]+)\]/, '$1').replace(/undefined/i, 'null');
		}
	},
	getUTCOffset: {
		enumerable: true,
		value: function (timestamp) {
			if (timestamp instanceof Date)
				timestamp = timestamp.valueOf();

			if (isNaN(timestamp))
				timestamp = Date.now();

			return new Intl.DateTimeFormat('en-us', {timeZone: 'America/New_York', timeZoneName: 'short'}).format(timestamp).match(/EDT/) ? -4 : -5;
		}
	}
});

Object.defineProperties(Date, {
	HNtoUTC: {
		enumerable: true,
		value: function () {
			var date = new Date(Date.UTC.apply(undefined, Array.prototype.slice.call(arguments, 0)));
			date.setUTCHours(date.getUTCHours() - getUTCOffset(date));
			return date.valueOf();
		}
	},
	LocaltoHN: {
		enumerable: true,
		value: function (date) {
			if (date instanceof Date)
				date = date.valueOf();

			if (isNaN(date))
				date = Date.now();

			var game = new Date(date);
			game.setHours(game.getHours() + parseInt(game.getTimezoneOffset() / 60) + parseInt(getUTCOffset()));
			game.setMinutes(game.getMinutes() + parseInt(game.getTimezoneOffset() % 60) + 60 * (getUTCOffset() - parseInt(getUTCOffset())));
			return game.valueOf();
		}
	}
});