Time: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(40 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Internal=
* [[ISO 8601]]
* [[RFC 822]]
* [[Java Time]]
=Definitions=
=Definitions=


==Standard Time==
==Standard Time==


''Standard time'' is the synchronization of clocks within a time zone to a single time value, rather than using solar time or local mean time standard. All clocks within the same timezone show the same time.
{{External|[https://en.wikipedia.org/wiki/Standard_time Standard Time in Wikipedia]}}


The standard time set in each time zone is defined in terms of offsets from [[#UTC|UTC]] and, in those time zones where daylight saving time is observed, by applying an additional offset corresponding to the daylight saving.
''Standard time'' is the synchronization of clocks within a time zone to a single time value, rather than using solar time or local mean time standard. All clocks within the same timezone show the same time. The standard time set in each time zone is defined in terms of offsets from [[#UTC|UTC]] and, in those time zones where daylight saving time is observed, by applying an additional offset corresponding to the daylight saving.


More details: https://en.wikipedia.org/wiki/Standard_time
==UTC==


==UTC==
{{External|[https://en.wikipedia.org/wiki/Universal_Time Universal Time in Wikipedia]}}


UTC (Coordinated Universal Time or Universal Time) is the primary time standard by which the world regulates time. UTC represents a moment in time within about 1 second of mean solar time at 0° longitude. UTC is an atomic timescale that approximates [[#UT1|UT1]]. It is a successor to GMT (Greenwich Mean Time). For most practical purposes, UTC is considered interchangeable with GMT, but GMT is no longer precisely defined by the scientific community.
UTC (Coordinated Universal Time or Universal Time) is the primary time standard by which the world regulates time. UTC represents a moment in time within about 1 second of mean solar time at 0° longitude. UTC is an atomic timescale that approximates [[#UT1|UT1]]. It is a successor to GMT (Greenwich Mean Time). For most practical purposes, UTC is considered interchangeable with GMT, but GMT is no longer precisely defined by the scientific community.
Line 17: Line 23:
UTC does not observe daylight savings time. The actual wall clock time in a time zone is obtained by applying the UTC offset and the daylight saving offset, if daylight saving time is observed and it is in effect in the timezone.
UTC does not observe daylight savings time. The actual wall clock time in a time zone is obtained by applying the UTC offset and the daylight saving offset, if daylight saving time is observed and it is in effect in the timezone.


UTC is specified as "0000" in RFC 822  
UTC is represented as "0000" in [[RFC_822#UTC_Representation|RFC 822]] and as and as "Z" in [[ISO_8601#UTC|ISO 8601]].


<pre>
==UT1==
15/01/01 01:01:01+0000
 
15/01/01 01:01:01 +0000
UT1 is the principal form of Universal Time. It conceptually mean solar time at 0° longitude. However, precise measurements of the Sun are difficult. Hence, it is computed from observations of distant quasars using long baseline interferometry, laser ranging of the Moon and artificial satellites, as well as the determination of GPS satellite orbits.
</pre>
 
==GMT==


and as "Z" in ISO 8601
See [[#UTC|UTC]]


<pre>
==<span id='Epoch'></span>The Epoch==
15/01/01 01:01:01 Z
</pre>


1 January 1970, 00:00:00.000 UTC <font color=darkgray>(Gregorian)</font>.


More details: https://en.wikipedia.org/wiki/Universal_Time
==POSIX Time==


==UT1==
{{External|[https://en.wikipedia.org/wiki/Unix_time Unix Time in Wikipedia]}}


UT1 is the principal form of Universal Time. It conceptually mean solar time at 0° longitude. However, precise measurements of the Sun are difficult. Hence, it is computed from observations of distant quasars using long baseline interferometry, laser ranging of the Moon and artificial satellites, as well as the determination of GPS satellite orbits.
Unix time (also known as POSIX time or epoch time) is a system for describing a point in time, defined as the number of ''seconds'' that have elapsed since 00:00:00 [[#UTC|UTC]] Thursday, 1 January 1970, 00:00:00, minus the number of leap seconds that have taken place since then.


==GMT==
==Millisecond POSIX Time==


See [[#UTC|UTC]]
A representation of a point in time with the same semantics as the [[#POSIX_Time|POSIX Time]], but using milliseconds instead of seconds.


==Time Zone==
==Time Zone==
{{External|[https://en.wikipedia.org/wiki/Time_zone Time Zone in Wikipedia]}}


A time zone is a region that observes the same standard time. All clocks within a time zone should indicate the same value. Most of the time zones are identified by offsets from [[#UTC|UTC]]. The actual wall clock time in a time zone is calculating by applying the time zone offset to UTC and, if daylight time is observed and it is effect, the daylight time offset.
A time zone is a region that observes the same standard time. All clocks within a time zone should indicate the same value. Most of the time zones are identified by offsets from [[#UTC|UTC]]. The actual wall clock time in a time zone is calculating by applying the time zone offset to UTC and, if daylight time is observed and it is effect, the daylight time offset.


The valid offsets from UTC range from UTC−12 to UTC+14. Most offset values are whole hours, but there are a few that include offset by 30 or 45 minutes.
Valid offsets from UTC range from UTC−12 to UTC+14. Most offset values are whole hours, but there are a few that include offset by 30 or 45 minutes.


"Z" is the zone designator for the zero UTC offset.
Different time representation standards represents time zone information differently. ISO 8601 represents time zone information as "Z", when the time is relative to [[#UTC|UTC]], and uses positive and negative offsets in the format ±hh:mm otherwise. More details are available in: {{Internal|ISO_8601#Time_Zone_Designators|ISO 8601 Time Zone Designators}}


Offsets from UTC are written in the format <tt>±[hh]:[mm]</tt>, <tt>±[hh][mm]</tt>, or <tt>±[hh]</tt>: hour(s) ahead or behind UTC. So if the time being described is one hour ahead of UTC (such as the time in Berlin during the winter), the zone designator would be "+01:00", "+0100", or simply "+01". The offset from UTC changes with daylight saving time, e.g. a time offset in Chicago, which is in the North American Central Time Zone, would be "−06:00" for the winter (Central Standard Time) and "−05:00" for the summer.
Java supports various time zone representations. For more details see {{Internal|Java_Time#Time_Zone|Time Zone Support in Java}}


<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
==Time Offset==
:[[Java Time#Time_Zone|Time Zone Support in Java]]
</blockquote>


For more details see: https://en.wikipedia.org/wiki/Time_zone
A time offset is an amount of time, in milliseconds, subtracted from or added to UTC to get the current wall clock time – whether it's standard time or daylight saving time. <span id='Time_Offset_Example'></span>As an example, during summer time, when the daylight saving time is in effect, the effective time offset from UTC in the Eastern Time Zone is -4 (-14400000 milliseconds). During winter time, when the standard time is observed, the effective time offset from UTC in the Easter Time Zone is -5 (-18000000 milliseconds).


==Time Offset==
For a time zone where the daylight saving time is not in effect, the time offset is the time zone offset.
 
{{Internal|Java Time#Raw_Time_Zone_Offset|Getting Raw Time Zone Offset in Java}}
 
For a time zone where the daylight saving time is in effect, the time offset is the time zone offset + the daylight saving time offset (usually one hour).


A time offset is an amount of time subtracted from or added to UTC to get the current wall clock time – whether it's standard time or daylight saving time.
{{Internal|Java Time#Daylight_Saving_Time_Offset|Getting Daylight Saving Time Offset in Java}}


==Daylight Saving Time==
==Daylight Saving Time==


More details: https://en.wikipedia.org/wiki/Daylight_saving_time
{{External|[https://en.wikipedia.org/wiki/Daylight_saving_time Daylight Saving Time in Wikipedia]}}
 
==Gregorian Calendar==
 
=Standards for Time Representation=
* [[ISO 8601]]
* [[RFC 822]]


=Interpreting Timestamps=
=Interpreting Timestamps=
Line 95: Line 111:
</pre>
</pre>


=Java Timezone Support=
=Time, Date, Timestamp Handling in Programming Languages=
 
==Time, Date, Timestamp Handling in Python==
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
{{Internal|Time, Date, Timestamp in Python#Overview|Time, Date, Timestamp in Python}}
:[[Java Timezone]]
==Time, Date, Timestamp Handling in Go==
</blockquote>
{{Internal|Time, Date, Timestamp in Go#Overview|Time, Date, Timestamp in Go}}

Latest revision as of 21:27, 8 October 2023

Internal

Definitions

Standard Time

Standard Time in Wikipedia

Standard time is the synchronization of clocks within a time zone to a single time value, rather than using solar time or local mean time standard. All clocks within the same timezone show the same time. The standard time set in each time zone is defined in terms of offsets from UTC and, in those time zones where daylight saving time is observed, by applying an additional offset corresponding to the daylight saving.

UTC

Universal Time in Wikipedia

UTC (Coordinated Universal Time or Universal Time) is the primary time standard by which the world regulates time. UTC represents a moment in time within about 1 second of mean solar time at 0° longitude. UTC is an atomic timescale that approximates UT1. It is a successor to GMT (Greenwich Mean Time). For most practical purposes, UTC is considered interchangeable with GMT, but GMT is no longer precisely defined by the scientific community.

Time zones around the world are expressed using positive or negative offsets from UTC.

UTC does not observe daylight savings time. The actual wall clock time in a time zone is obtained by applying the UTC offset and the daylight saving offset, if daylight saving time is observed and it is in effect in the timezone.

UTC is represented as "0000" in RFC 822 and as and as "Z" in ISO 8601.

UT1

UT1 is the principal form of Universal Time. It conceptually mean solar time at 0° longitude. However, precise measurements of the Sun are difficult. Hence, it is computed from observations of distant quasars using long baseline interferometry, laser ranging of the Moon and artificial satellites, as well as the determination of GPS satellite orbits.

GMT

See UTC

The Epoch

1 January 1970, 00:00:00.000 UTC (Gregorian).

POSIX Time

Unix Time in Wikipedia

Unix time (also known as POSIX time or epoch time) is a system for describing a point in time, defined as the number of seconds that have elapsed since 00:00:00 UTC Thursday, 1 January 1970, 00:00:00, minus the number of leap seconds that have taken place since then.

Millisecond POSIX Time

A representation of a point in time with the same semantics as the POSIX Time, but using milliseconds instead of seconds.

Time Zone

Time Zone in Wikipedia

A time zone is a region that observes the same standard time. All clocks within a time zone should indicate the same value. Most of the time zones are identified by offsets from UTC. The actual wall clock time in a time zone is calculating by applying the time zone offset to UTC and, if daylight time is observed and it is effect, the daylight time offset.

Valid offsets from UTC range from UTC−12 to UTC+14. Most offset values are whole hours, but there are a few that include offset by 30 or 45 minutes.

Different time representation standards represents time zone information differently. ISO 8601 represents time zone information as "Z", when the time is relative to UTC, and uses positive and negative offsets in the format ±hh:mm otherwise. More details are available in:

ISO 8601 Time Zone Designators

Java supports various time zone representations. For more details see

Time Zone Support in Java

Time Offset

A time offset is an amount of time, in milliseconds, subtracted from or added to UTC to get the current wall clock time – whether it's standard time or daylight saving time. As an example, during summer time, when the daylight saving time is in effect, the effective time offset from UTC in the Eastern Time Zone is -4 (-14400000 milliseconds). During winter time, when the standard time is observed, the effective time offset from UTC in the Easter Time Zone is -5 (-18000000 milliseconds).

For a time zone where the daylight saving time is not in effect, the time offset is the time zone offset.

Getting Raw Time Zone Offset in Java

For a time zone where the daylight saving time is in effect, the time offset is the time zone offset + the daylight saving time offset (usually one hour).

Getting Daylight Saving Time Offset in Java

Daylight Saving Time

Daylight Saving Time in Wikipedia

Gregorian Calendar

Standards for Time Representation

Interpreting Timestamps

Assuming that the timestamp is "07/10/16 10:00:00 -0400", it can be read as follows: the timestamp represents the value the clock time at the moment it was displayed, and it was obtained from the UTC value at that moment by applying the offset of -4 * 3600 * 1000 milliseconds. The value of the corresponding UTC timestamp (milliseconds passed since 01/01/1970 00:00:00 Z) can be calculated by adding 4 * 3600 * 1000 milliseconds to the number of milliseconds passed between 01/01/1972 00:00:00.000 and 07/10/16 10:00:00. The timestamp also says that the effective offset of the timezone the reading was performed in is -04:00 relative to UTC.

The timestamp does not says that, but the reading was performed in the Eastern Daylight Saving Time, where the Eastern Standard Time time zone offset is -5 hours, and the daylight saving time offset (in effect) is +1 hour, so -0400 = -5 + 1.

How Do Applications Get the Local Time Zone Information?

Applications obtain the current timezone from the system via the localtime API (for more details see man localtime). The timezone information used by localtime and exposed to the API clients is initialized based on the value of the TZ environment variable, as it follows (this applies to Mac/BSD, update it for other platforms):

  • If TZ does not appear in the environment, the best available approximation to local wall clock time is read from /etc/localtime.
  • If TZ appears in the environment but its value is a null string, Coordinated Universal Time (UTC) is used.
  • If TZ appears in the environment and its value begins with a colon (`:'), the rest of its value is used as a pathname of a tzfile-format file from which to read the time conversion information. If the first character of the pathname is a slash (`/'), it is used as an absolute pathname; otherwise, it is used as a pathname relative to the system time conversion information directory.
  • If TZ appears in the environment and its value does not begin with a colon, it is first used as the pathname of a file, as described above, from which to read the time conversion information. Conventionally, the files are available under /usr/share/zoneinfo and the file name designates the corresponding timezone. If that file cannot be read, the value is then interpreted as a direct specification of the time conversion information.
  • If the TZ environment variable does not specify a tzfile-format file and cannot be interpreted as a direct specification, UTC is used.

Example

Setting TZ to:

export TZ=/usr/share/zoneinfo/Pacific/Honolulu

causes date to output this:

Tue Jul 12 14:32:47 HST 2016

Time, Date, Timestamp Handling in Programming Languages

Time, Date, Timestamp Handling in Python

Time, Date, Timestamp in Python

Time, Date, Timestamp Handling in Go

Time, Date, Timestamp in Go