Exemple #1
0
    def test_festival(self):
        this1 = pytime.new_year(2015) == datetime.date(2015, 1, 1)
        self.assertTrue(this1)
        this2 = pytime.valentine(2014) == datetime.date(2014, 2, 14)
        self.assertTrue(this2)
        this3 = pytime.fool(2013) == datetime.date(2013, 4, 1)
        self.assertTrue(this3)
        this4 = pytime.christmas(2012) == datetime.date(2012, 12, 25)
        self.assertTrue(this4)
        this5 = pytime.christ_eve(2011) == datetime.date(2011, 12, 24)
        self.assertTrue(this5)
        this6 = pytime.mother(2010) == datetime.date(2010, 5, 9)
        self.assertTrue(this6)
        this7 = pytime.father(2009) == datetime.date(2009, 6, 21)
        self.assertTrue(this7)
        this8 = pytime.halloween(2008) == datetime.date(2008, 10, 31)
        self.assertTrue(this8)
        this9 = pytime.easter(2007) == datetime.date(2007, 4, 8)
        self.assertTrue(this9)
        this10 = pytime.thanks(2006) == datetime.date(2006, 11, 23)
        self.assertTrue(this10)

        this11 = pytime.vatertag(2020) == datetime.date(2020, 5, 21)
        self.assertTrue(this11)
        this12 = pytime.vatertag(2021) == datetime.date(2021, 5, 13)
        self.assertTrue(this12)
        this13 = pytime.vatertag(2025) == datetime.date(2025, 5, 29)
        self.assertTrue(this13)
Exemple #2
0
 def test_festival(self):
     this1 = pytime.new_year(2015) == datetime.date(2015, 1, 1)
     self.assertTrue(this1)
     this2 = pytime.valentine(2014) == datetime.date(2014, 2, 14)
     self.assertTrue(this2)
     this3 = pytime.fool(2013) == datetime.date(2013, 4, 1)
     self.assertTrue(this3)
     this4 = pytime.christmas(2012) == datetime.date(2012, 12, 25)
     self.assertTrue(this4)
     this5 = pytime.christ_eve(2011) == datetime.date(2011, 12, 24)
     self.assertTrue(this5)
     this6 = pytime.mother(2010) == datetime.date(2010, 5, 9)
     self.assertTrue(this6)
     this7 = pytime.father(2009) == datetime.date(2009, 6, 21)
     self.assertTrue(this7)
     this8 = pytime.halloween(2008) == datetime.date(2008, 10, 31)
     self.assertTrue(this8)
     this9 = pytime.easter(2007) == datetime.date(2007, 4, 8)
     self.assertTrue(this9)
     this10 = pytime.thanks(2006) == datetime.date(2006, 11, 23)
     self.assertTrue(this10)
from pytime import pytime  # This is from the documentation

# Mother's Day.
print(pytime.mother(1977))

# Father's Day.
print(pytime.father(1977))

# Easter Sunday.
print(pytime.easter(1977))
Exemple #4
0
# random int from a range - add a 3rd arg for a step
# print(random.randrange(2, 200, 4))

# choose a random float from a range
# x = random.uniform(2, 200)
# print(x)

# return a sample from the given collection with the size given
# sample = random.sample(roygbiv, 3)
# print(sample)

# prints random float between 0.0 and 1.0
# print(random.random())

# all modules are packages but not all packages are modules. packages are larger

# pytime is not a standard packages, needs to be installed with pip
# pytime is a package that contains a module called pytime, so you need to write this syntax
from pytime import pytime

mothers = pytime.mother(1)
print(mothers)

print(pytime.tomorrow())

print(pytime.last_week())