Unix Timestamp

class Foundation_API DateTime
	/// This class represents an instant in time, expressed
	/// in years, months, days, hours, minutes, seconds
	/// and milliseconds based on the Gregorian calendar.
	/// The class is mainly useful for conversions between
	/// UTC, Julian day and Gregorian calendar dates.
	///
	/// The date and time stored in a DateTime is always in UTC
	/// (Coordinated Universal Time) and thus independent of the 
	/// timezone in effect on the system.
	///
	/// Conversion calculations are based on algorithms
	/// collected and described by Peter Baum at
	/// http://vsg.cape.com/~pbaum/date/date0.htm
	///
	/// Internally, this class stores a date/time in two
	/// forms (UTC and broken down) for performance reasons. Only use 
	/// this class for conversions between date/time representations.
	/// Use the Timestamp class for everything else.
	///
	/// Notes:
	///   * Zero is a valid year (in accordance with ISO 8601 and astronomical year numbering)
	///   * Year zero (0) is a leap year
	///   * Negative years (years preceding 1 BC) are not supported
	///
	/// For more information, please see:
	///   * http://en.wikipedia.org/wiki/Gregorian_Calendar
	///   * http://en.wikipedia.org/wiki/Julian_day
	///   * http://en.wikipedia.org/wiki/UTC
	///   * http://en.wikipedia.org/wiki/ISO_8601


Epoch:

指的是一个特定的时间:1970-01-01 00:00:00 UTC。
UNIX时间戳:Unix时间戳(英文为Unix time, POSIX time 或 Unix timestamp)是从Epoch(1970年1月1日00:00:00 UTC)开始所经过的秒数,不考虑闰秒。

时间戳是自 1970 年 1 月 1 日(00:00:00 GMT)以来的秒数。它也被称为 Unix 时间戳(Unix Timestamp)。

Unix时间戳(Unix timestamp),或称Unix时间(Unix time)、POSIX时间(POSIX time),是一种时间表示方式,定义为从格林威治时间1970年01月01日00时00分00秒起至现在的总秒数。Unix时间戳不仅被使用在Unix系统、类Unix系统中,也在许多其他操作系统中被广泛采用。

UTC:

协调世界时(英:Coordinated Universal Time ,法:Temps Universel Coordonné),又称世界统一时间,世界标准时间,国际协调时间。英文(CUT)和法文(TUC)的缩写不同,作为妥协,简称UTC。

/// Monotonic UTC time value in 100 nanosecond resolution,
/// with base time midnight, October 15, 1582.

The Gregorian calendar is internationally the most widely used civil calendar. It is named after Pope Gregory XIII, who introduced it in October 1582.

Julian_day:

一般广泛用于 天文计时

闰年判断:

inline bool DateTime::isLeapYear(int year)
{
return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0);
}

原文地址:https://www.cnblogs.com/scotth/p/6979331.html