using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.Skyscraper
{
	internal static class LongExtensions
	{
		/// <summary>
		/// 
		/// </summary>
		/// <param name="l"></param>
		/// <remarks>stolen from https://stackoverflow.com/a/250400</remarks>
		/// <returns></returns>
		public static DateTime AsUnixtime(this long l)
		{
			DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
			dateTime = dateTime.AddSeconds(l);
			return dateTime;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="l"></param>
		/// <remarks>stolen from https://stackoverflow.com/a/250400</remarks>
		/// <returns></returns>
		public static DateTime AsJavaMillis(this long javaTimeStamp)
		{
			// Java timestamp is milliseconds past epoch
			DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
			dateTime = dateTime.AddMilliseconds(javaTimeStamp);
			return dateTime;
		}
	}
}
