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
def year(ctx, date): """ Returns only the year of a date """ return conversions.to_date_or_datetime(date, ctx).year
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))
def month(ctx, date): """ Returns only the month of a date (1 to 12) """ return conversions.to_date_or_datetime(date, ctx).month
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
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))
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])