Skip to content

chibisov/mcfly-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

McFly machine

Marty McFly machine for python

from mcfly_machine import Machine as m
from datetime import datetime

print datetime.now()
# => datetime.datetime(2012, 2, 23, 22, 11, 40, 283787)

print m(5).days.ago()
# => datetime.datetime(2012, 2, 18, 22, 11, 40, 283787)

For single component you can use singular form:

print m(1).day.later()
# => datetime.datetime(2012, 2, 24, 22, 11, 40, 283787)
m(1).hour.ago()

Not only ints:

m(1.5).hours.ago()

You can chain date components with 'and_' method:

m(9).days.and_(8).hours.ago()
m(9).days.and_(8).hours.and_(1).second.and_(10).microseconds.later()

By default timedelta calculates from datetime.now(). You can change it:

m(9).days.ago(from_=datetime(1990, 2, 3))

Force to use datetime.utcnow():

m(9).days.ago(in_utc=True)

About

Marty McFly machine for python. m(6).days.ago()

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages