Дата и время: безысходность бытия

ЛКШ 2015.Август

Дата и время:
безысходность бытия

ЛКШ 2015.Август

Секунда

Что такое секунда?

Секунда есть время, равное 9 192 631 770 периодам излучения, соответствующего переходу между двумя сверхтонкими уровнями основного состояния атома цезия-133.

XIII Генеральная конференция по мерам и весам, 1967 год

Секунда, символ с, является единицей времени; её величина устанавливается фиксацией численного значения частоты сверхтонкого расщепления основного состояния атома цезия-133 при температуре 0 К равным в точности 9 192 631 770, когда она выражена единицей СИ с−1, что эквивалентно Гц.

XXIV Генеральная конференция по мерам и весам, 2011 год

Как хранится время?

  1. UNIX-время — количество секунд, прошедшее с  (почти)
    • Если хранить в 32-битном числе (от −231 до 231 − 1), времена будут от  до  (проблема 2038 года)
    • Если хранить в 64-битном числе, переполнение случится
  2. В Windows время хранится по-разному.
    Например, FILETIME — количество сотен наносекунд (10−7 секунды) с . (Хранится в 64-битном типе и переполнится в 30828 году.)

Секунда

Синхронизация времени

Network Time Protocol (NTP)

Хранение времени в NTP

Хватит ли 128 бит?

The 64 bit value for the fraction is enough to resolve the amount of time it takes a photon to pass an electron at the speed of light. The 64 bit second value is enough to provide unambiguous time representation until the universe goes dim.

David L. Mills, NTP designer

64-битного числа для дробной части достаточно для хранения времени, за которое фотон на скорости света преодолевает электрон. 64-битного числа для количества секунд хватит для однозначного представления времени до того момента, когда Вселенная потускнеет.

Дэвид Миллс, разработчик NTP

Секунда

Високосная секунда

Високосная секунда: что это?

Кто вводит?

Центр ориентации Земли Международной службы вращения Земли (Earth Orientation Center of the International Earth Rotation and reference System Service)

To authorities responsible for the measurement and distribution of time

UTC TIME STEP
on the 1st of July 2015

A positive leap second will be introduced at the end of June 2015.
The sequence of dates of the UTC second markers will be:

2015 June 30,     23h 59m 59s
2015 June 30,     23h 59m 60s
2015 July  1,      0h  0m  0s

В чём же проблема?

Високосная секунда и NTP

Високосная секунда и Google

http://googleblog.blogspot.co.uk/2011/09/time-technology-and-leaping-seconds.html

Час

История часа

День и ночь

День и ночь в Древней Руси

Час

Часовые пояса

Часовые пояса

Как выглядят часовые пояса в Антарктиде?

Час

Летнее и зимнее время

Летнее и зимнее время: зачем?

Опять Австралия...

Часовой пояс Зимой Летом
Australia/Lord_Howe UTC+10:30 UTC+11
Antarctica/Macquarie UTC+11
Australia/Hobart, Australia/Currie,
Australia/Melbourne, Australia/Sydney
UTC+10 UTC+11
Australia/Broken_Hill, Australia/Adelaide UTC+09:30 UTC+10:30
Australia/Brisbane, Australia/Lindeman UTC+10
Australia/Darwin UTC+09:30
Australia/Perth UTC+08
Australia/Eucla UTC+08:45
Pacific/Norfolk UTC+11:30

Бывает и интереснее

Марокко переводит часы на время Рамадана

Час

Смена часовых поясов

Зачем менять часовые пояса?

Чтобы лучше жить

Чтобы было удобнее

По политическим причинам

C 15 августа Северная Корея переходит с UTC+9 на UTC+8:30

Японские милитаристы совершили такое непростительное преступление, как лишение Кореи её собственного времени, наряду с попытками растоптать ее историю и культуру, насчитывающие 5 тысяч лет, и уничтожить корейскую нацию

Центральное телеграфное агентство Кореи

Как вычислить точное время?

Бинарный поиск!

			def fromutc(self, dt):
			    # ...
			    dt = dt.replace(tzinfo=None)
			    idx = max(0, bisect_right(self._utc_transition_times, dt) - 1)
			    inf = self._transition_info[idx]
			    return (dt + inf[0]).replace(tzinfo=self._tzinfos[inf])
			 
			def bisect_right(a, x, lo=0, hi=None):
			    # ...
			    while lo < hi:
			        mid = (lo+hi)//2
			        if x < a[mid]: hi = mid
			        else: lo = mid+1
			    return lo
		

Часы

tzdata

Формат данных

Zone Europe/Moscow
2:30:17 -      LMT     1880
2:30:17 -      MMT     1916 Jul  3 # Moscow Mean Time
2:31:19 Russia %s      1919 Jul  1  2:00
3:00   Russia  %s      1921 Oct
3:00   Russia  MSK/MSD 1922 Oct
2:00   -       EET     1930 Jun 21
3:00   Russia  MSK/MSD 1991 Mar 31  2:00s
2:00   Russia  EE%sT   1992 Jan 19  2:00s
3:00   Russia  MSK/MSD 2011 Mar 27  2:00s
4:00   -       MSK     2014 Oct 26  2:00s
3:00   -       MSK

Srednekolymsk and Zyryanka are the most populous places amongst these districts, but have very similar populations. In fact, Wikipedia currently lists them both as having 3528 people, exactly 1668 males and 1860 females each! (Yikes!)
http://en.wikipedia.org/w/?title=Srednekolymsky_District&oldid=603435276
http://en.wikipedia.org/w/?title=Verkhnekolymsky_District&oldid=594378493
Assume this is a mistake, albeit an amusing one.

Looking at censuses, the populations of the two municipalities seem to have fluctuated recently. Zyryanka was more populous than Srednekolymsk in the 1989 and 2002 censuses, but Srednekolymsk was more populous in the most recent (2010) census, 3525 to 3170. (See pages 195 and 197 of http://www.gks.ru/free_doc/new_site/perepis2010/croc/Documents/Vol1/pub-01-05.pdf in Russian.) In addition, Srednekolymsk appears to be a much older settlement and the population of Zyryanka seems to be declining.
Go with Srednekolymsk.

From Dave Cantor (2004-11-02):

Early this summer I had the occasion to visit the Mount Washington Observatory weather station atop (of course!) Mount Washington [, NH]... One of the staff members said that the station was on Eastern Standard Time and didn’t change their clocks for Daylight Saving ... so that their reports will always have times which are 5 hours behind UTC.

Since Mount Washington has a climate all its own, I guess it makes sense for it to have its own time as well.

From Paul Eggert (1999-03-31):

Shanks writes that Michigan started using standard time on 1885-09-18, but Howse writes (pp 124-125, referring to Popular Astronomy, 1901-01) that Detroit kept local time until 1900 when the City Council decreed that clocks should be put back twenty-eight minutes to Central Standard Time. Half the city obeyed, half refused. After considerable debate, the decision was rescinded and the city reverted to Sun time. A derisive offer to erect a sundial in front of the city hall was referred to the Committee on Sewers. Then, in 1905, Central time was adopted by city vote.

This story is too entertaining to be false, so go with Howse over Shanks.

Martin Bruckmann (1996-02-29) reports via Peter Ilieve

that Portugal is reverting to 0:00 by not moving its clocks this spring.
The new Prime Minister was fed up with getting up in the dark in the winter.

From Even Scharning (2013-10-25):

The scheduled end of DST in Libya on Friday, October 25, 2013 was cancelled yesterday

http://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/

Часы

Программистские
тонкости

			>>> from datetime import *
>>> from pytz import *
>>> tz = timezone('Europe/Moscow')
>>> tz.utcoffset(datetime(2015, 8, 9, 14, 0, 0))
datetime.timedelta(0, 10800)
>>> tz.utcoffset(datetime(2014, 8, 9, 14, 0, 0))
datetime.timedelta(0, 14400)
			>>> from datetime import *
>>> from pytz import *
>>> tz = timezone('Europe/Moscow')
>>> tz.utcoffset(datetime(2014, 10, 26, 1, 30, 0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python341\lib\site-packages\pytz-2015.4-py3.4.egg\pytz\tzinfo.py", line 408, in utcoffset
  File "C:\Python341\lib\site-packages\pytz-2015.4-py3.4.egg\pytz\tzinfo.py", line 349, in localize
pytz.exceptions.AmbiguousTimeError: 2014-10-26 01:30:00
			>>> tz.utcoffset(datetime(2011, 3, 27, 0, 0, 0))
datetime.timedelta(0, 10800)
>>> tz.utcoffset(datetime(2011, 3, 27, 10, 0, 0))
datetime.timedelta(0, 14400)
>>> tz.utcoffset(datetime(2011, 3, 27, 2, 30, 0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python341\lib\site-packages\pytz-2015.4-py3.4.egg\pytz\tzinfo.py", line 408, in utcoffset
  File "C:\Python341\lib\site-packages\pytz-2015.4-py3.4.egg\pytz\tzinfo.py", line 327, in localize
pytz.exceptions.NonExistentTimeError: 2011-03-27 02:30:00

Летоисчисление

Римский календарь

Римский календарь: начало

Римский календарь: развитие

Летоисчисление

Юлианский календарь

Юлианский календарь: введение

Месяц / Год 47 до н. э. 46 до н. э.
Январь 29 29
Февраль 28 24
Интеркаларий 27
Март 31 31
Апрель 29 29
Май 31 31
Июнь 29 29
Квинтиль 31 31
Месяц / Год 47 до н. э. 46 до н. э.
Секстиль 29 29
Сентябрь 29 29
Октябрь 31 31
Ноябрь 29 29
* 33
* 34
Декабрь 29 29
Всего 355 445

Юлианский календарь: развитие

Юлианский календарь: проблемы

Летоисчисление

Григорианский календарь

Григорианский календарь

Переход с Юлианского

Переход с Юлианского

Переход с Юлианского в Англии

Переход с Юлианского в Норвегии

Летоисчисление

Другие календари

Еврейский календарь

Исламский календарь

Я ленточка!