ariovistus / pyd

Interoperability between Python and D
MIT License
158 stars 32 forks source link

automatic DateTime conversion #25

Closed Laeeth closed 8 years ago

Laeeth commented 9 years ago

please could you include something like this? written for PyDMagic - preinit is called before python initialization and postInit after. but same idea in pure pyd.

You might want to include handling second fractions properly and timezones for a systime. The below was enough for me for now.

void preInit() { import pyd.pyd; import deimos.python.datetime; import std.datetime; ex_d_to_python((DateTime dt) => PyDateTime_FromDateAndTime( dt.year.to!int,dt.month.to!int,dt.day.to!int,dt.hour.to!int,dt.minute.to!int,dt.second.to!int,0)); }

void postInit() { import pyd.pyd; import deimos.python.datetime; PyDateTime_IMPORT(); }

ariovistus commented 8 years ago

41 implements this