Days till Christmas How To

This post is a follow-up from ‘Easy Way to Get the Difference of Two Times in Python’, seen here. If confused, please read that first, then come back to this.


So, continuing from where we left off, lets say we want to get the number of days till christmas. For that, we’d do the following.

#! /usr/bin/python3

import arrow

class CustomArrow(arrow.Arrow):
    def days_till_xmas(self):
        xmas = arrow.Arrow(self.year, 12, 25)
        if self > xmas:
            xmas = xmas.replace(years=1)

        return (xmas - self).days

factory = arrow.ArrowFactory(CustomArrow)
mytime =

And boom, that’s it!

Bookmark the permalink.

  • If this page or post could use some sprucing up, let us know by contacting us through this link