Converted code from Time::Piece to DateTime