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)
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)
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
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))
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)
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))
def __new__(cls, *args, **kargs): d = parser.parse(*args, **kargs) d = pydate.__new__(cls, d.year, d.month, d.day) return d
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
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)
def __new__(cls, year: int, month: int, day: int, *_: Any) -> date: return date.__new__(cls, year, month, day)
def __new__(cls, y, m, d): return date.__new__(cls, y, m, d)
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)
def __new__(cls, year, month, day): return date.__new__(cls, year, month, day)
def __new__(cls, value, *_): # type: (date, ...) -> date return date.__new__(cls, value.year, value.month, value.day)
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)