Trying to convert between standard python datetime routine datetime.datetime and Pyphem routine ephem.Date sometimes there are (except the expected truncation) peculiar differences in the range of one second.
Try the example code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ephem
import datetime
now_datetime = datetime.datetime.now()
now_ephem = ephem.Date(now_datetime)
print "Datetime: ", now_datetime
print "Ephem : ", now_ephem
Repeated calls give an output similar to:
thl@thl-lap-001:$ ./timedifference.py
Datetime: 2013-12-20 08:28:11.536814
Ephem : 2013/12/20 08:28:11
thl@thl-lap-001:$ ./timedifference.py
Datetime: 2013-12-20 08:28:16.088484
Ephem : 2013/12/20 08:28:15
The last two lines show 16.somethig seconds in Datetim that converts to 15 Seconds to ephem.Date.
Is there an explanation?