@samatawy/rules
    Preparing search index...

    Date/Time Functions

    Use snake_case names in new rules. Where a camelCase compatibility alias exists, it is listed below the heading.

    Alternative syntax: sameInstant(left, right).

    Returns true when two dates represent the same instant.

    if sent_at.same_instant(received_at) then synced = true
    

    Returns true when the first date is earlier than the second.

    if now().before(due_date) then still_open = true
    
    • This can be confusing, so using the syntax date1 BEFORE date2 is highly advisable.

    Returns true when the first date is later than the second.

    if now().after(expiry_date) then expired = true
    
    • This can be confusing, so using the syntax date2 AFTER date1 is highly advisable.

    Alternative syntax: sameYear(left, right).

    Returns true when both dates are in the same year.

    if sameYear(createdAt, now()) then currentYear = true
    

    Alternative syntax: sameMonth(left, right).

    Returns true when both dates are in the same month of the same year.

    if sameMonth(invoiceDate, today()) then currentMonth = true
    

    Alternative syntax: sameWeek(left, right).

    Returns true when both dates fall in the same week.

    if sameWeek(orderDate, today()) then recentOrder = true
    

    Alternative syntax: sameDay(left, right).

    Returns true when both dates fall on the same calendar day.

    if sameDay(createdAt, today()) then newToday = true
    

    Alternative syntax: sameHour(left, right).

    Returns true when both dates fall in the same hour.

    if sameHour(startedAt, now()) then currentHour = true
    

    Alternative syntax: sameMinute(left, right).

    Returns true when both dates fall in the same minute.

    if sameMinute(sentAt, now()) then justSent = true
    

    Alternative syntax: sameSecond(left, right).

    Returns true when both dates fall in the same second.

    if sameSecond(updatedAt, now()) then instantMatch = true
    

    Returns the four-digit year.

    set yyyy = order_date.year()
    

    Returns the month number from 1 to 12.

    Provided constants include JAN, FEB, etc. Use these to make your declarations more readable.

    IF month(today()) IN [JAN, FEB, NOV, DEC] THEN season = 'winter'
    

    Returns the week number within the year.

    set ww = order_date.week()
    

    Returns the day of the month.

    set dd = day(orderDate)
    

    Returns the day of week from 1 to 7.

    Provided constants include MON, TUE, etc. Use these to make your declarations more readable.

    IF weekday(today()) IN [SAT, SUN] THEN weekend = TRUE 
    

    Returns the hour of the day.

    set hh = created_at.hour()
    

    Returns the minute component.

    set mi = created_at.minute()
    

    Returns the second component.

    set ss = created_at.second()
    

    Return the UNIX timestamp, i.e. milliseconds that have passed since the Unix Epoch (January 1, 1970, 00:00:00 UTC).

    set exactly_when = created_at.instant()
    

    Alternative syntax: addYears(date, years). Adds years to a date.

    set renewal_date = start_date.add_years(1)
    

    Alternative syntax: addMonths(date, months). Adds months to a date.

    set due_date = invoice_date.add_months(1)
    

    Alternative syntax: addWeeks(date, weeks). Adds weeks to a date.

    set follow_up = today().add_weeks(2)
    

    Alternative syntax: addDays(date, days). Adds days to a date.

    set deadline = created_at.add_days(7)
    

    Alternative syntax: addHours(date, hours). Adds hours to a date.

    set expires_at = now().add_hours(4)
    

    Alternative syntax: addMinutes(date, minutes). Adds minutes to a date.

    set reminder_at = now().add_minutes(30)
    

    Alternative syntax: addSeconds(date, seconds). Adds seconds to a date.

    set timeout_at = now().add_seconds(45)
    

    Alternative syntax: subtractYears(date, years). Subtracts years from a date.

    set lookback = today().subtract_years(5)
    

    Alternative syntax: subtractMonths(date, months). Subtracts months from a date.

    set previous_quarter = today().subtract_months(3)
    

    Alternative syntax: subtractWeeks(date, weeks). Subtracts weeks from a date.

    set prior_review = today().subtract_weeks(2)
    

    Alternative syntax: subtractDays(date, days). Subtracts days from a date.

    set grace_start = due_date.subtract_days(10)
    

    Alternative syntax: subtractHours(date, hours). Subtracts hours from a date.

    set opened_at = now().subtract_hours(1)
    

    Alternative syntax: subtractMinutes(date, minutes). Subtracts minutes from a date.

    set warmup_start = now().subtract_minutes(15)
    

    Alternative syntax: subtractSeconds(date, seconds). Subtracts seconds from a date.

    set retry_at = now().subtract_seconds(10)
    

    Returns the current date and time.

    set createdAt = now()
    

    Returns today's date with the time set to midnight.

    set businessDate = today()
    

    Returns the first day of the current year.

    set fiscalAnchor = yearStart()
    

    Returns the last day of the current year.

    set periodEnd = yearEnd()
    

    Returns the first day of the current month.

    set statementStart = monthStart()
    

    Returns the last day of the current month.

    set statementEnd = monthEnd()