Forums

We really need Arrow for Better Dates and Times

How do we request access to import arrow?

As most know, dates and times are not pretty in python and converting UTC to Local time is a bear.

Arrow just works:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/usr/bin/env python3
# jeff@consultski.com

# better date and time functions for python
import arrow
utc     = arrow.utcnow()
now     = utc.to('US/Eastern')
tWday   =now.format("dddd")
tDate   =now.format("MMMM D YYYY")
tHour   =now.format("H:mm A")
tStamp  ='Last update On ' + tWday + ', ' + tDate + ' at ' + tHour + ' US Eastern time. '
print(tStamp)

#output
# Last update On Friday, September 29 2017 at 4:33 AM US Eastern time.

arrow docs

Here you go http://help.pythonanywhere.com/pages/InstallingNewModules/

Awesome. Even better, it worked!

It no longer works, at least not from cron?

ImportError: No module named arrow

Are you running it in the same environment that you installed it in? i.e. the same version of Python and/or the same virtualenv.

it is a file run by cron... you talk of web files for virtualenv, how do i ensure that cron will run the virtualenv?

do you honor the shebang for cron job?

By cron, do you mean a task you've set up on the scheduled tasks tab? (It's a bit of a nit-pick, I know, but I just wanted to make sure.)

Anyway, if so, this help page should explain everything -- just let us know if it doesn't help.

yes. cron = scheduled tasks. sorry

thanks. i could not find that link. that should solve it.

Maybe we should add the word "cron" next to the link to it on the help index page -- you're not the only one using the normal Unix terminology :-)

Yes.

aka cron or crontab

It has been too long, but the job scheduler for IBM's MVS was something like AutoRun and you might want to reference it too. {grin}

But what was the terminology for ENIAC? ;-)

I've added "similar to cron" to the section of the help page that describes scheduled tasks, hopefully that'll make it a bit more discoverable.