Python

Write an awesome doc for Python. A very nice an practical one extracted from Python official documentation.

View on GitHub

Date & Time

Imagine you wanna build an app which enables its users to schedule virtual meetings. And your user base is gonna be international. So how you’re gonna deal with topics such as different countries timezones, daylight saving time, etc.

Fortunately Python comes to rescue with its built-in datetime module :mechanical_arm:. But lets first learn about them a bit:

Timezones

Jargons

</tbody> </table> > Fun fact: > > When I used the term interesting earlier, I did not meant as something which is fascinating, but I meant it as in the old curse: > >
"May you live in Interesting times"
## Some 3rd-party Libs - [pytz](https://pypi.org/project/pytz/). - [dateutils](https://pypi.org/project/dateutils/). > [!Note] > > If you're using Python version 3.9 or higher we probably do not need them since python supports timezone and a lot of other stuff out of the box in those versions. > [!CAUTION] > > If you need to work with Persian, Chinese or other calendars the `datetime` module won't cut it.
JargonDefinition
The Unix epoch The epoch is the reference point from which Unix time starts counting. Defined as midnight (00:00 UTC) on January 1, 1970 (why this date?).
UTC Coordinated Universal Time. The primary time standard globally used to regulate clocks and time (Why UTC and not CUT?). Times will be measured against UTC.
GMT
  • Stands for Greenwich Mean Time.
  • The local mean time at the Royal Observatory in Greenwich, London, counted from midnight. In simpler terms it is a timezone and no longer a time standard (it used to be a time standard though).
  • </td> </tr>
The IANA timezone database
  • AKA Olson database, tz database.
  • Contains code & data representing the history of local time for many locations around the globe.
  • Its publicly available and Linux updates its TZ database as part of regular updates it does.
  • E.g. "Asia/Tokyo" which the first part is the name of ocean/continent, and the last part is the name of a major city.
DST Acronym of Daylight Saving Time. Time goes one hour:
  • Forward in spring.
  • Back in autumn.