##-*- coding: utf-8 -*-
#!/usr/bin/python
"""
Utilities related to Dates.
"""
import datetime
import unittest

__author__ = 'SeomGi, Han'
__credits__ = ['SeomGi, Han']
__copyright__ = 'Copyright 2015, Python Utils Project'

__license__ = 'MIT'
__version__ = '0.0.1'
__maintainer__ = 'SeomGi, Han'
__email__ = 'iandmyhand@gmail.com'
__status__ = 'Development'


class TestDateUtils(unittest.TestCase):

    def test_is_valid_date(self):
        self.assertTrue(DateUtils().is_valid_date('20151021'))
        self.assertFalse(DateUtils().is_valid_date('20151041'))
        self.assertFalse(DateUtils().is_valid_date('2015102'))
        self.assertFalse(DateUtils().is_valid_date('20151000'))

    def test_get_first_date_of_next_month(self):
        base_datetime = datetime.datetime(2016, 12, 31)
        next_month = DateUtils().get_first_date_of_next_month(base_datetime=base_datetime)
        self.assertEqual(1, next_month.month)
        base_datetime = datetime.datetime(2016, 1, 1)
        next_month = DateUtils().get_first_date_of_next_month(base_datetime=base_datetime)
        self.assertEqual(2, next_month.month)


class DateUtils:

    def is_valid_date(self, birth_date):
        """
        Usage:
            DateUtils().is_valid_date('20151021')  # True
            DateUtils().is_valid_date('20151041')  # False
        Args:
            birth_date:

        Returns:

        """
        
        if 8 != len(birth_date):
            return False

        if not birth_date.isdigit():
            return False

        try:
            datetime.datetime.strptime(birth_date, '%Y%m%d')
        except ValueError:
            return False

        return True

    def get_first_date_of_next_month(self, base_datetime=datetime.datetime.today()):
        """
        Usage:

        Args:
            base_datetime: datetime
        """
        if 12 < base_datetime.month + 1:
            return datetime.date(base_datetime.year + 1, 1, 1)
        else:
            return datetime.date(base_datetime.year, base_datetime.month + 1, 1)


if __name__ == '__main__':
    unittest.main()

@@ -742,36 +742,32 @@
        base_date
-time
  = datetime.date
@@ -848,36 +848,32 @@
 _month(base_date
-time
 =base_datetime)%0A
@@ -858,36 +858,32 @@
 e_date=base_date
-time
 )%0A        self.a
@@ -931,20 +931,16 @@
 ase_date
-time
  = datet
@@ -1035,20 +1035,16 @@
 ase_date
-time
 =base_da
@@ -1045,20 +1045,16 @@
 ase_date
-time
 )%0A      
@@ -1698,20 +1698,16 @@
 ase_date
-time
 =datetim
@@ -1754,16 +1754,247 @@
  Usage:%0A
+            DateUtils().get_first_date_of_next_month() # if today is 2016.2.24 then return datetime.date(2016, 3, 1)%0A            DateUtils().get_first_date_of_next_month(datetime.datetime(2016, 12, 31))  # datetime.date(2017, 1, 1)
 %0A       
@@ -2021,20 +2021,16 @@
 ase_date
-time
 : dateti
@@ -2031,16 +2031,21 @@
 datetime
+.date
 %0A       
@@ -2066,36 +2066,32 @@
 f 12 %3C base_date
-time
 .month + 1:%0A    
@@ -2124,28 +2124,24 @@
 te(base_date
-time
 .year + 1, 1
@@ -2201,20 +2201,16 @@
 ase_date
-time
 .year, b
@@ -2217,20 +2217,16 @@
 ase_date
-time
 .month +

Update get_first_date_of_next_month: change parameter name to base_date from base_datetime and add usage comment.