Best way to convert datetime betwen Python and D

Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 2 13:46:43 PDT 2015


Hi.
What's the best way to convert a D std.datetime DateTime to a 
Python datetime.datetime and back again ?  PyD allows for custom 
conversion methods in D, but that is not much use if I don't know 
how to make the conversion on the D side.  I could obviously 
split out into y,m,d,h,m,s again, but I would rather not as these 
are fields in an array of structs that I would like to be able to 
do things easily with in Python.

Calling an embedded Python interpreter to create a datetime pyd 
object and sending that back over does work, but it's hardly 
ideal...


Laeeth.


More information about the Digitalmars-d-learn mailing list