here is the snippet

data = ''2007-12-31 Name (mike) Age (34).....'
gregorian = time.strftime(data.split(" ")[0])
print gregorian
this gives me "2007-12-31"

i need to convert the gregorian date in the variable to julian date.
i tried this but it gives me the current date
julian = time.strftime('%j', time.localtime())

Recommended Answers

All 3 Replies

Python deals only with the Gregorian calendar. Certain terms (like "Julian") can be properly applied to specific things withing the Gregorian system, but the Julian calendar it is not.

Usually the Proleptic Gregorian calendar serves well enough for modern computing tasks...

Try googling "gregorian julian" for conversion algorithms. Good luck.

Unfortunately, the "Julian Day Number" is one of those terms I mentioned (or rather, it is often abused to mean "the day of the year").

Fortunately it looks like that link uses the JDN correctly! Nice catch!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.