Evernote database f...
 
Notifications
Clear all

Evernote database files

16 Posts
5 Users
0 Reactions
2,014 Views
(@angrybadger)
Estimable Member
Joined: 18 years ago
Posts: 164
 

FWIW the script runs in Python 2.7.

I've wrapped it in a GUI for ease of use.
The script is written to be expandable. Modification instructions included.
Again this script runs in Python 2.7

Link below https://www.dropbox.com/s/50t9bk3v2j7mdiy/DateConvertor.pyw


   
ReplyQuote
(@alexc)
Reputable Member
Joined: 16 years ago
Posts: 301
 

In case your errors were coming from trying to run the code under Python 3.x I've taken the liberty of tweaking it to work in that

import datetime

def ordinalToGregorian(o)
l = int(o)
d = datetime.datetime.fromordinal(l)
t = datetime.timedelta(seconds=((24 * 60 * 60) * (o-l)))
#print(d + t)
return d + t

print(ordinalToGregorian(735095.593981482))

(hmorgan I've also switched to using the datetime rather than the date constructor for fromordinal because then you can just add the timedelta object to it which is arguably a bit easier to read, hope you don't mind!)


   
ReplyQuote
(@angrybadger)
Estimable Member
Joined: 18 years ago
Posts: 164
 

In case your errors were coming from trying to run the code under Python 3.x I've taken the liberty of tweaking it to work in that

import datetime

def ordinalToGregorian(o)
l = int(o)
d = datetime.datetime.fromordinal(l)
t = datetime.timedelta(seconds=((24 * 60 * 60) * (o-l)))
#print(d + t)
return d + t

print(ordinalToGregorian(735095.593981482))

(hmorgan I've also switched to using the datetime rather than the date constructor for fromordinal because then you can just add the timedelta object to it which is arguably a bit easier to read, hope you don't mind!)

I said it was hacky. ?


   
ReplyQuote
(@alexc)
Reputable Member
Joined: 16 years ago
Posts: 301
 

I said it was hacky. ?

No criticism implied, I hope it didn't come across that way! It worked absolutely fine under 2.7, I just thought the error might have been coming from running it under 3.x so I made the one small tweak to make it run under 3.x (just the difference between print being a statement in 2.x but a function in 3.x).


   
ReplyQuote
(@angrybadger)
Estimable Member
Joined: 18 years ago
Posts: 164
 

I said it was hacky. ?

No criticism implied, I hope it didn't come across that way! It worked absolutely fine under 2.7, I just thought the error might have been coming from running it under 3.x so I made the one small tweak to make it run under 3.x (just the difference between print being a statement in 2.x but a function in 3.x).

None taken.
The differences with the Python versions are … interesting.
I've hung back from moving to 3.x as the libs I've been working with (opencv) weren't supported.
The print thing is annoying.

Anyhoo I've "upgraded" my date time convertor to work in python3 (i.e. I've decapitalised every instance of Tkinter roll )

https://www.dropbox.com/s/7ipb5pdmiwg7qc4/DateConvertor%20v3.x.pyw


   
ReplyQuote
(@alexc)
Reputable Member
Joined: 16 years ago
Posts: 301
 

One thing that, as far as DF work goes, is much better in Py3k (in my opinion) is the segregation of text and binary data. Text strings are always made up of Unicode characters, binary data (bytes objects) are just strings of integers from 0 to 255. It makes working with binary data a load easier. It's just a shame that a lot of cool projects still haven't migrated (and that opencv library looks really cool. I might have a play with that…)


   
ReplyQuote
Page 2 / 2
Share: