Beispiel #1
0
    def weekdayHalf(self):
        """
		%a
		"""
        if self.english:
            return EnglishChar.half_day(self.npDateTime.week_day)
        return NepaliChar.half_day(self.npDateTime.week_day)
Beispiel #2
0
    def yearFull(self):
        """
		%Y
		"""
        if self.english:
            return str(self.npDateTime.year)
        return NepaliChar.number(self.npDateTime.year)
Beispiel #3
0
    def monthFull(self):
        """
		%B or %b
		"""
        if self.english:
            return EnglishChar.month(self.npDateTime.month)
        return NepaliChar.month(self.npDateTime.month)
Beispiel #4
0
    def weekdayNumber(self):
        """
		%w
		"""
        if self.english:
            return str(self.npDateTime.week_day - 1)
        return NepaliChar.number(self.npDateTime.week_day - 1)
Beispiel #5
0
    def weekdayFull(self):
        """
		%A
		"""
        if self.english:
            return EnglishChar.day(self.npDateTime.week_day)
        return NepaliChar.day(self.npDateTime.week_day)
Beispiel #6
0
    def yearHalf(self):
        """
		%y
		"""
        if self.english:
            return str(self.npDateTime.year)[2:]
        return NepaliChar.number(str(self.npDateTime.year)[2:])
Beispiel #7
0
    def day_nonzero(self):
        """
		%D
		"""
        day = str(self.npDateTime.day)
        if self.english:
            return str(day)
        return NepaliChar.number(day)
Beispiel #8
0
    def monthNumber_nonzero(self):
        """
		%m
		"""
        month = str(self.npDateTime.month)
        if self.english:
            return str(month)
        return NepaliChar.number(month)
Beispiel #9
0
    def second_nonzero(self):
        """
		%S
		"""
        second = str(self.npDateTime.second)
        if self.english:
            return str(second)
        return NepaliChar.number(second)
Beispiel #10
0
    def hour24_nonzero(self):
        """
		%H
		"""
        hour = self.npDateTime.hour
        if self.english:
            return str(hour)
        return NepaliChar.number(hour)
Beispiel #11
0
    def minute_nonzero(self):
        """
		%M
		"""
        minute = str(self.npDateTime.minute)
        if self.english:
            return str(minute)
        return NepaliChar.number(minute)
Beispiel #12
0
    def second(self):
        """
		%S
		"""
        second = str(self.npDateTime.second)
        if len(second) < 2:
            second = '0' + second
        if self.english:
            return str(second)
        return NepaliChar.number(second)
Beispiel #13
0
    def minute(self):
        """
		%M
		"""
        minute = str(self.npDateTime.minute)
        if len(minute) < 2:
            minute = '0' + minute
        if self.english:
            return str(minute)
        return NepaliChar.number(minute)
Beispiel #14
0
    def hour24(self):
        """
		%H
		"""
        hour = str(self.npDateTime.hour)
        if len(hour) < 2:
            hour = '0' + hour
        if self.english:
            return str(hour)
        return NepaliChar.number(hour)
Beispiel #15
0
    def day(self):
        """
		%d
		"""
        day = str(self.npDateTime.day)
        if len(day) < 2:
            day = '0' + day
        if self.english:
            return str(day)
        return NepaliChar.number(day)
Beispiel #16
0
    def monthNumber(self):
        """
		%m
		"""
        month = str(self.npDateTime.month)
        if len(month) < 2:
            month = '0' + month
        if self.english:
            return str(month)
        return NepaliChar.number(month)
Beispiel #17
0
    def hour12_nonzero(self):
        """
		%I
		"""
        hour = self.npDateTime.hour
        if hour > 12:
            hour = hour - 12
        if hour == 0:
            hour = 12
        hour = str(hour)
        if self.english:
            return str(hour)
        return NepaliChar.number(hour)
Beispiel #18
0
    def get_humanize(self):
        """
		returns humanize datetime
		"""
        self.__calc_seconds()  # refreshing seconds

        interval_value = 0
        interval_text = ""
        if (self.seconds == 0):
            # now
            return self.__now_text

        elif (self.seconds < 60):
            # seconds
            interval_value = self.seconds
            interval_text = self.__second_text

        elif (self.seconds < 3600):
            # minute
            interval_value = self.seconds // 60
            interval_text = self.__minute_text

        elif (self.seconds < 86400):
            # hour
            interval_value = self.seconds // 3600
            interval_text = self.__hour_text

        elif (self.seconds < 2592000):
            # day
            interval_value = self.seconds // 86400
            interval_text = self.__day_text

        elif (self.seconds < 946080000):
            # month
            interval_value = self.seconds // 2592000
            interval_text = self.__month_text

        else:
            # year
            interval_value = self.seconds // 946080000
            interval_text = self.__year_text

        interval_value = NepaliChar.number(interval_value)
        return str(interval_value) + ' ' + str(
            interval_text) + ' ' + self.interval_tense