I am trying to change python datetime into matlab datenum by using this and this
def datetime2matlabdn(dt):
ord = dt.toordinal()
mdn = dt + timedelta(days = 366)
frac = (dt-datetime(dt.year,dt.month,dt.day,0,0,0)).seconds / (24.0 * 60.0 * 60.0)
return mdn.toordinal() + frac
when I call datetime2matlabdn(2021-08-28 10:30:00) it throws FOLLOWING ERRORS
datetime2matlabdn(2021-08-28 10:30:00)
Syntax Error: invalid token
what is wrong with my syntax? if I try to remove these zeros then it throws invalid syntax error. I figured out I need to strip the zeros I tried some thing like this but it is not working
dt=dt.strptime('2021-06-28 10:30','%Y-%m-%d %H:%M')
dn=datetime2matlabdn(dt)
how can I strip my zeros in function. any help would be appreciated.