예제 #1
0
 def __new__(cls, *args, **kwargs):
     yy = args[0]
     mm = args[1:2][0] if args[1:2] else 0
     dd = args[2:3][0] if args[2:3] else 0
     if isinstance(args[0], str):
         yy = parse(args[0])
     if isinstance(yy, date) or isinstance(yy, datetime):
         dd = yy.day
         mm = yy.month
         yy = yy.year
     try:
         return date.__new__(cls, yy, mm, dd, **kwargs)
     except:
         vals = tuple([1900, 1, 1])
         return date.__new__(cls, *vals)
예제 #2
0
 def __new__(cls, *args, **kwargs):
     yy = args[0]
     mm = args[1:2][0] if args[1:2] else 0
     dd = args[2:3][0] if args[2:3] else 0
     if isinstance(args[0], str):
         yy = parse(args[0])
     if isinstance(yy, date) or isinstance(yy, datetime):
         dd = yy.day
         mm = yy.month
         yy = yy.year
     try:
         return date.__new__(cls, yy, mm, dd, **kwargs)
     except:
         vals = tuple([1900, 1, 1])
         return date.__new__(cls, *vals)
예제 #3
0
 def __new__(cls, *args, **kwargs):
     if len(args) == 1:
         if isinstance(args[0], basetime):
             raise TypeError("bdateutil.date cannot be initialized with "
                             "just a time")
         args = parse(args[0]).timetuple()[:3]
     return basedate.__new__(cls, *args, **kwargs)
예제 #4
0
 def __new__(cls, *args, **kwargs):
     if len(args) == 1:
         if isinstance(args[0], basetime):
             raise TypeError("bdateutil.date cannot be initialized with "
                             "just a time")
         args = parse(args[0]).timetuple()[:3]
     return basedate.__new__(cls, *args, **kwargs)
예제 #5
0
 def __new__(cls, year, month, day, leap=False):
     obj = date.__new__(cls, *lun2sol(year, month, day, leap)[:3])
     object.__setattr__(obj, 'lunaryear', year)
     object.__setattr__(obj, 'lunarmonth', month)
     object.__setattr__(obj, 'lunarday', day)
     object.__setattr__(obj, 'lunarleap', leap)
     return obj
예제 #6
0
 def __new__(cls, year, month, day, leap=False):
     obj = date.__new__(cls, *lun2sol(year, month, day, leap)[:3])
     object.__setattr__(obj, 'lunaryear', year)
     object.__setattr__(obj, 'lunarmonth', month)
     object.__setattr__(obj, 'lunarday', day)
     object.__setattr__(obj, 'lunarleap', leap)
     return obj
 def __new__(cls, string: str = None):
     str_list = string.split('/')
     year = int(str_list[2])
     month = int(str_list[0])
     day = int(str_list[1])
     self = date.__new__(cls, year, month, day)
     return self
예제 #8
0
파일: dt.py 프로젝트: santiagogaray/ladybug
 def __new__(cls, month=1, day=1, leap_year=False):
     """Create Ladybug Date.
     """
     year = 2016 if leap_year else 2017
     try:
         return date.__new__(cls, year, month, day)
     except ValueError as e:
         raise ValueError("{}:\n\t({}/{})(m/d)".format(e, month, day))
예제 #9
0
 def __new__(self, *args, **kwargs):
     if len(args) == 1:
         args = parse(args[0]).timetuple()[:3]
     if len(args) > 2:
         if args[2] == 99:
             args = list(args)
             args[2] = calendar.monthrange(args[0], args[1])[1]
     return basedate.__new__(self, *args, **kwargs)
예제 #10
0
 def __new__(self, *args, **kwargs):
     if len(args) == 1:
         args = parse(args[0]).timetuple()[:3]
     if len(args) > 2:
         if args[2] == 99:
             args = list(args)
             args[2] = calendar.monthrange(args[0], args[1])[1]
     return basedate.__new__(self, *args, **kwargs)
예제 #11
0
파일: dt.py 프로젝트: polandar/ladybug
    def __new__(cls, month=1, day=1, leap_year=False):
        """Create Ladybug Date.

        Args:
            month: A value for month between 1-12 (Defualt: 1).
            day: A value for day between 1-31 (Defualt: 1).
            leap_year: A boolean to indicate if date is for a leap year
                (Default: False).
        """
        year = 2016 if leap_year else 2017
        try:
            return date.__new__(cls, year, month, day)
        except ValueError as e:
            raise ValueError("{}:\n\t({}/{})(m/d)".format(e, month, day))
예제 #12
0
 def __new__(cls, *args, **kargs):
     d = parser.parse(*args, **kargs)
     d = pydate.__new__(cls, d.year, d.month, d.day)
     return d
예제 #13
0
 def __new__(cls, year, month, day, name, name_en):
     obj = date.__new__(cls, year, month, day)
     obj.name = name
     obj.name_en = name_en
     return obj
예제 #14
0
 def __new__(cls, *args, **kwargs):
     return date.__new__(date, *args, **kwargs)
 def __new__(cls, year, month, day, *_):  # type: (int, int, int, ...) -> date
     return date.__new__(cls, year, month, day)
예제 #16
0
 def __new__(cls, year: int, month: int, day: int, *_: Any) -> date:
     return date.__new__(cls, year, month, day)
예제 #17
0
 def __new__(cls, y, m, d):
     return date.__new__(cls, y, m, d)
예제 #18
0
 def __new__ (cls, *args, **kwargs):
     if type(args[0]) == int:
         return date.__new__(cls, *args, **kwargs)
     else:
         d = args[0]
         return date.__new__(cls, d.year, d.month, d.day)
예제 #19
0
파일: parser.py 프로젝트: danae/iffgraph
 def __new__(cls, year, month, day):
     return date.__new__(cls, year, month, day)
예제 #20
0
 def __new__(cls, year, month, day, name, name_en):
     obj = date.__new__(cls, year, month, day)
     obj.name = name
     obj.name_en = name_en
     return obj
예제 #21
0
파일: items.py 프로젝트: zooba/pipenv
 def __new__(cls, value, *_):  # type: (date, ...) -> date
     return date.__new__(cls, value.year, value.month, value.day)
예제 #22
0
 def __new__(cls, date_str: str):
     date_tuple = get_date_tuple(date_str)
     month, day, yr = date_tuple
     return date.__new__(cls, yr, month, day)