Example #1
0
def weekday(ctx, date):
    """
    Returns the day of the week of a date (1 for Sunday to 7 for Saturday)
    """
    return ((conversions.to_date_or_datetime(date, ctx).weekday() + 1) % 7) + 1
Example #2
0
def year(ctx, date):
    """
    Returns only the year of a date
    """
    return conversions.to_date_or_datetime(date, ctx).year
Example #3
0
def edate(ctx, date, months):
    """
    Moves a date by the given number of months
    """
    return conversions.to_date_or_datetime(
        date, ctx) + relativedelta(months=conversions.to_integer(months, ctx))
Example #4
0
def month(ctx, date):
    """
    Returns only the month of a date (1 to 12)
    """
    return conversions.to_date_or_datetime(date, ctx).month
Example #5
0
def year(ctx, date):
    """
    Returns only the year of a date
    """
    return conversions.to_date_or_datetime(date, ctx).year
Example #6
0
def day(ctx, date):
    """
    Returns only the day of the month of a date (1 to 31)
    """
    return conversions.to_date_or_datetime(date, ctx).day
Example #7
0
def weekday(ctx, date):
    """
    Returns the day of the week of a date (1 for Sunday to 7 for Saturday)
    """
    return ((conversions.to_date_or_datetime(date, ctx).weekday() + 1) % 7) + 1
Example #8
0
def month(ctx, date):
    """
    Returns only the month of a date (1 to 12)
    """
    return conversions.to_date_or_datetime(date, ctx).month
Example #9
0
def edate(ctx, date, months):
    """
    Moves a date by the given number of months
    """
    return conversions.to_date_or_datetime(date, ctx) + relativedelta(months=conversions.to_integer(months, ctx))
Example #10
0
def day(ctx, date):
    """
    Returns only the day of the month of a date (1 to 31)
    """
    return conversions.to_date_or_datetime(date, ctx).day
Example #11
0
def weeknum(ctx, date):
    """
    Returns the num of the week of a date (Between 1 and 52)
    """
    return (conversions.to_date_or_datetime(date, ctx).isocalendar()[1])