Achievments in 2016

| Comments

A list of my most important achievments in 2016:

  • started a new job at MailInBlack & LetSignIt, like it.
  • used a lot of different technologies: flask, celery, angular, mondodb, scala, docker, azure & google clouds, google app engine

strftime for datetime before 1900 year

| Comments

Recently I’ve got an error for birthdays before 1900 year

ValueError: year=1890 is before 1900; the datetime strftime() methods require year >= 1900

for this code:

import datetime
datetime.date(1890,7,1).strftime('%d.%m.%Y')

And it’s described in the documentation

The full set of format codes supported varies across platforms, because Python calls the platform C library’s strftime() function, and platform variations are common. To see the full set of format codes supported on your platform, consult the strftime(3) documentation.
The exact range of years for which strftime() works also varies across platforms. Regardless of platform, years before 1900 cannot be used.

One of the ways to solve this:

birthday = datetime.date(1890,7,1)
'{0.day:02d}.{0.month:02d}.{0.year:4d}'.format(birthday)
« 12/13 »