Python Glossary Русский

all Python 3sqlite3function

sqlite3.DateFromTicks()

DB-API: date and time

A DB-API standard function: builds a datetime.date from seconds since the epoch (like time.time()) using the local time zone.

Syntax

sqlite3.DateFromTicks(ticks)

It wraps time.localtime, so the date depends on the machine's time zone: second 0 is 1 January 1970 in UTC but still 31 December 1969 in New York. The module docs do not describe it; it exists for PEP 249 compatibility, and in your own code datetime.date.fromtimestamp(ts) says the same thing more clearly.

Examples

import datetime
import sqlite3
print(sqlite3.DateFromTicks(0))  # → ? 1970-01-01 в UTC, зависит от часового пояса
print(sqlite3.DateFromTicks(0) == datetime.date.fromtimestamp(0))  # → True
print(type(sqlite3.DateFromTicks(0)).__name__)  # → date

See also

Open in the full glossarydocs.python.orgReport an inaccuracy