Assuming you are writing a custom template function, the following gets the first three digits of the year with a trailing 0. It doesn't check for the 'undefined' date (1/1/0101).
Code:
def evaluate(self, formatter, kwargs, mi, locals):
x = (mi.pubdate.year/10)*10
return '%04d'%x