Enhancement: add timezones to all date functions

This commit is contained in:
olliemath 2021-08-08 10:05:35 +01:00
parent 1054502d5d
commit 45e16fe2f8

View File

@ -400,103 +400,103 @@ class F(Cond, FunctionOperatorsMixin, metaclass=FMeta):
# Functions for working with dates and times # Functions for working with dates and times
@staticmethod @staticmethod
def toYear(d): def toYear(d, timezone=NO_VALUE):
return F("toYear", d) return F("toYear", d, timezone)
@staticmethod @staticmethod
def toISOYear(d, timezone=""): def toISOYear(d, timezone=NO_VALUE):
return F("toISOYear", d, timezone) return F("toISOYear", d, timezone)
@staticmethod @staticmethod
def toQuarter(d, timezone=""): def toQuarter(d, timezone=NO_VALUE):
return F("toQuarter", d, timezone) if timezone else F("toQuarter", d) return F("toQuarter", d, timezone)
@staticmethod @staticmethod
def toMonth(d): def toMonth(d, timezone=NO_VALUE):
return F("toMonth", d) return F("toMonth", d, timezone)
@staticmethod @staticmethod
def toWeek(d, mode=0, timezone=""): def toWeek(d, mode=0, timezone=NO_VALUE):
return F("toWeek", d, mode, timezone) return F("toWeek", d, mode, timezone)
@staticmethod @staticmethod
def toISOWeek(d, timezone=""): def toISOWeek(d, timezone=NO_VALUE):
return F("toISOWeek", d, timezone) if timezone else F("toISOWeek", d) return F("toISOWeek", d, timezone)
@staticmethod @staticmethod
def toDayOfYear(d): def toDayOfYear(d, timezone=NO_VALUE):
return F("toDayOfYear", d) return F("toDayOfYear", d, timezone)
@staticmethod @staticmethod
def toDayOfMonth(d): def toDayOfMonth(d, timezone=NO_VALUE):
return F("toDayOfMonth", d) return F("toDayOfMonth", d, timezone)
@staticmethod @staticmethod
def toDayOfWeek(d): def toDayOfWeek(d, timezone=NO_VALUE):
return F("toDayOfWeek", d) return F("toDayOfWeek", d, timezone)
@staticmethod @staticmethod
def toHour(d): def toHour(d, timezone=NO_VALUE):
return F("toHour", d) return F("toHour", d, timezone)
@staticmethod @staticmethod
def toMinute(d): def toMinute(d, timezone=NO_VALUE):
return F("toMinute", d) return F("toMinute", d, timezone)
@staticmethod @staticmethod
def toSecond(d): def toSecond(d, timezone=NO_VALUE):
return F("toSecond", d) return F("toSecond", d, timezone)
@staticmethod @staticmethod
def toMonday(d): def toMonday(d, timezone=NO_VALUE):
return F("toMonday", d) return F("toMonday", d, timezone)
@staticmethod @staticmethod
def toStartOfMonth(d): def toStartOfMonth(d, timezone=NO_VALUE):
return F("toStartOfMonth", d) return F("toStartOfMonth", d, timezone)
@staticmethod @staticmethod
def toStartOfQuarter(d): def toStartOfQuarter(d, timezone=NO_VALUE):
return F("toStartOfQuarter", d) return F("toStartOfQuarter", d, timezone)
@staticmethod @staticmethod
def toStartOfYear(d): def toStartOfYear(d, timezone=NO_VALUE):
return F("toStartOfYear", d) return F("toStartOfYear", d, timezone)
@staticmethod @staticmethod
def toStartOfISOYear(d): def toStartOfISOYear(d, timezone=NO_VALUE):
return F("toStartOfISOYear", d) return F("toStartOfISOYear", d, timezone)
@staticmethod @staticmethod
def toStartOfTenMinutes(d): def toStartOfTenMinutes(d, timezone=NO_VALUE):
return F("toStartOfTenMinutes", d) return F("toStartOfTenMinutes", d, timezone)
@staticmethod @staticmethod
def toStartOfWeek(d, mode=0): def toStartOfWeek(d, timezone=NO_VALUE):
return F("toStartOfWeek", d) return F("toStartOfWeek", d, timezone)
@staticmethod @staticmethod
def toStartOfMinute(d): def toStartOfMinute(d, timezone=NO_VALUE):
return F("toStartOfMinute", d) return F("toStartOfMinute", d, timezone)
@staticmethod @staticmethod
def toStartOfFiveMinute(d): def toStartOfFiveMinute(d, timezone=NO_VALUE):
return F("toStartOfFiveMinute", d) return F("toStartOfFiveMinute", d, timezone)
@staticmethod @staticmethod
def toStartOfFifteenMinutes(d): def toStartOfFifteenMinutes(d, timezone=NO_VALUE):
return F("toStartOfFifteenMinutes", d) return F("toStartOfFifteenMinutes", d, timezone)
@staticmethod @staticmethod
def toStartOfHour(d): def toStartOfHour(d, timezone=NO_VALUE):
return F("toStartOfHour", d) return F("toStartOfHour", d, timezone)
@staticmethod @staticmethod
def toStartOfDay(d): def toStartOfDay(d, timezone=NO_VALUE):
return F("toStartOfDay", d) return F("toStartOfDay", d, timezone)
@staticmethod @staticmethod
def toTime(d, timezone=""): def toTime(d, timezone=NO_VALUE):
return F("toTime", d, timezone) return F("toTime", d, timezone)
@staticmethod @staticmethod
@ -504,47 +504,47 @@ class F(Cond, FunctionOperatorsMixin, metaclass=FMeta):
return F("toTimeZone", dt, timezone) return F("toTimeZone", dt, timezone)
@staticmethod @staticmethod
def toUnixTimestamp(dt, timezone=""): def toUnixTimestamp(dt, timezone=NO_VALUE):
return F("toUnixTimestamp", dt, timezone) return F("toUnixTimestamp", dt, timezone)
@staticmethod @staticmethod
def toYYYYMM(dt, timezone=""): def toYYYYMM(dt, timezone=NO_VALUE):
return F("toYYYYMM", dt, timezone) if timezone else F("toYYYYMM", dt) return F("toYYYYMM", dt, timezone)
@staticmethod @staticmethod
def toYYYYMMDD(dt, timezone=""): def toYYYYMMDD(dt, timezone=NO_VALUE):
return F("toYYYYMMDD", dt, timezone) if timezone else F("toYYYYMMDD", dt) return F("toYYYYMMDD", dt, timezone)
@staticmethod @staticmethod
def toYYYYMMDDhhmmss(dt, timezone=""): def toYYYYMMDDhhmmss(dt, timezone=NO_VALUE):
return F("toYYYYMMDDhhmmss", dt, timezone) if timezone else F("toYYYYMMDDhhmmss", dt) return F("toYYYYMMDDhhmmss", dt, timezone)
@staticmethod @staticmethod
def toRelativeYearNum(d, timezone=""): def toRelativeYearNum(d, timezone=NO_VALUE):
return F("toRelativeYearNum", d, timezone) return F("toRelativeYearNum", d, timezone)
@staticmethod @staticmethod
def toRelativeMonthNum(d, timezone=""): def toRelativeMonthNum(d, timezone=NO_VALUE):
return F("toRelativeMonthNum", d, timezone) return F("toRelativeMonthNum", d, timezone)
@staticmethod @staticmethod
def toRelativeWeekNum(d, timezone=""): def toRelativeWeekNum(d, timezone=NO_VALUE):
return F("toRelativeWeekNum", d, timezone) return F("toRelativeWeekNum", d, timezone)
@staticmethod @staticmethod
def toRelativeDayNum(d, timezone=""): def toRelativeDayNum(d, timezone=NO_VALUE):
return F("toRelativeDayNum", d, timezone) return F("toRelativeDayNum", d, timezone)
@staticmethod @staticmethod
def toRelativeHourNum(d, timezone=""): def toRelativeHourNum(d, timezone=NO_VALUE):
return F("toRelativeHourNum", d, timezone) return F("toRelativeHourNum", d, timezone)
@staticmethod @staticmethod
def toRelativeMinuteNum(d, timezone=""): def toRelativeMinuteNum(d, timezone=NO_VALUE):
return F("toRelativeMinuteNum", d, timezone) return F("toRelativeMinuteNum", d, timezone)
@staticmethod @staticmethod
def toRelativeSecondNum(d, timezone=""): def toRelativeSecondNum(d, timezone=NO_VALUE):
return F("toRelativeSecondNum", d, timezone) return F("toRelativeSecondNum", d, timezone)
@staticmethod @staticmethod
@ -568,7 +568,7 @@ class F(Cond, FunctionOperatorsMixin, metaclass=FMeta):
return F("timeSlots", start_time, F.toUInt32(duration)) return F("timeSlots", start_time, F.toUInt32(duration))
@staticmethod @staticmethod
def formatDateTime(d, format, timezone=""): def formatDateTime(d, format, timezone=NO_VALUE):
return F("formatDateTime", d, format, timezone) return F("formatDateTime", d, format, timezone)
@staticmethod @staticmethod