Your void print2digits is probably just stuck inside of some other function on account of curly bracket misuse.
Don't know if it's relevant to your setup, but I had to also
#include <TimeLib.h>
to the RTC examples included in the IDE for my RTC to work