classSolution{public:stringconvertDateToBinary(stringdate){constintyear=stoi(date.substr(0,4));constintmonth=stoi(date.substr(5,2));constintday=stoi(date.substr(8,2));returntoBinary(year)+'-'+toBinary(month)+'-'+toBinary(day);}private:// Converts an integer to binary without leading zeros.stringtoBinary(intvalue){conststringbinary=bitset<16>(value).to_string();returnbinary.substr(binary.find('1'));// Remove leading zeros.}};
classSolution:defconvertDateToBinary(self,date:str)->str:year,month,day=map(int,date.split('-'))deftoBinary(value:int)->str:"""Converts an integer to binary without leading zeros."""returnbin(value)[2:]return'-'.join([toBinary(year),toBinary(month),toBinary(day)])