Does anyone know of a way to convert from a Julian date to a regular calendar date?
Answer
I take no credit for the following Python snippet, which is taken from an ESRI idea found by Googling 'convert from julian to calendar date arcgis'. As trivia, they mention the data they were working with came from the FAA. There is also mention of data coming over from Excel in that format despite being entered differently.
I apologize if my cut/paste screws up any formatting, nor do I know if it works or needs modification. I have minimal (recent) programming experience but tried to replicate it as best I could in this interface.
def julianDateToDate(jDate):
_jdatere = re.compile("(?P\d{4})(?P\d{3})")
match =_jdatere.match(jDate)
if match:
d = match.groupdict()
year = int(d["year"])
days = int(d["days"])
date = datetime.date(year,1,1) + datetime.timedelta(days=days-1)
return date
No comments:
Post a Comment