예제 #1
0
    def test_random_conversions(self):
        for rd_maps in RANDOM_CONVERSION_MAPS:
            nep_date = NepaliDate(**rd_maps['nep'])
            eng_date = datetime.date(**rd_maps['eng'])
            eng_date_trans = nep_date.to_english_date()

            assert eng_date_trans == eng_date
예제 #2
0
    def test_to_english_date(self):
        date_nepali = NepaliDate(MIN_DATE['year'], MIN_DATE['month'],
                                 MIN_DATE['day'])
        date_english = date_nepali.to_english_date()

        assert date_english.year == REFERENCE_DATE_AD['year']
        assert date_english.month == REFERENCE_DATE_AD['month']
        assert date_english.day == REFERENCE_DATE_AD['day']
예제 #3
0
파일: admin.py 프로젝트: anupadkh/tripathi
 def nep_date(self, obj):
     try:
         # valid_dob = (self.date.split('-'))
         return NepaliDate.to_nepali_date(obj.date)
     except:
         return '-'
     return
예제 #4
0
    def test_to_nepali_date(self):
        date_english = datetime.date(REFERENCE_DATE_AD['year'],
                                     REFERENCE_DATE_AD['month'],
                                     REFERENCE_DATE_AD['day'])
        date_nepali = NepaliDate.to_nepali_date(date_ad=date_english)

        assert date_nepali.year == MIN_DATE['year']
        assert date_nepali.month == MIN_DATE['month']
        assert date_nepali.day == MIN_DATE['day']
예제 #5
0
 def test_max_date(self):
     nep_date = NepaliDate(2051, 10, 1)
     assert MAX_DATE['year'] == nep_date.max.year
     assert MAX_DATE['month'] == nep_date.max.month
     assert MAX_DATE['day'] == nep_date.max.day
예제 #6
0
 def test_min_date(self):
     nep_date = NepaliDate(2051, 10, 1)
     assert MIN_DATE['year'] == nep_date.min.year
     assert MIN_DATE['month'] == nep_date.min.month
     assert MIN_DATE['day'] == nep_date.min.day
예제 #7
0
 def test_strfdate(self):
     nep_date = NepaliDate(2051, 10, 1)
     assert nep_date.strfdate('%y %m %d %a') == '51 10 01 Sun'
     assert nep_date.strfdate('%Y %A') == '2051 Sunday'
     assert nep_date.strfdate('%b %B') == 'Mag Magh'
예제 #8
0
 def test_today(self):
     nep_date = NepaliDate.today(lang='eng')
     assert 1 <= nep_date.day <= 32
     assert 1 <= nep_date.month <= 12
예제 #9
0
 def test_strpdate(self):
     nep_date = NepaliDate.strpdate(' 2051/10/01', fmt=' %Y/%m/%d')
     assert nep_date == NepaliDate(2051, 10, 1)
예제 #10
0
 def save(self, *args, **kwargs):
     if self.nepali_date != "":
         self.date = NepaliDate.to_english_date(
             NepaliDate(*self.nepali_date.split('-')))
     super(Payment, self).save(*args, **kwargs)