Back to Lowdefy

@lowdefy/operators-dayjs

code-docs/plugins/operators/dayjs.md

5.2.01.8 KB
Original Source

@lowdefy/operators-dayjs

Date and time operators using Day.js.

Operators

OperatorPurpose
_dayjsFull Day.js operations
_dateSimplified date operations

_date

Simple date operations:

yaml
# Current date/time
now:
  _date: now

# Format current date
formatted:
  _date:
    - now
    - format: YYYY-MM-DD

# Parse and format
displayDate:
  _date:
    - _state: dateString
    - format: MMMM D, YYYY

# Add/subtract time
nextWeek:
  _date:
    - now
    - add:
        - 7
        - days

_dayjs

Full Day.js API:

yaml
# Create dayjs instance
date:
  _dayjs:
    - '2024-01-15'
    - YYYY-MM-DD

# Chain operations
result:
  _dayjs:
    on:
      _state: startDate
    operations:
      - - add
        - 1
        - month
      - - startOf
        - month
      - - format
        - YYYY-MM-DD

Common Operations

Format Tokens

TokenOutput
YYYY2024
MM01-12
DD01-31
HH00-23
mm00-59
ss00-59
MMMMJanuary
ddddMonday

Relative Time

yaml
ago:
  _dayjs:
    on:
      _state: createdAt
    operations:
      - - fromNow

Difference

yaml
daysBetween:
  _dayjs:
    on:
      _state: endDate
    operations:
      - - diff
        - _state: startDate
        - days

Comparison

yaml
isAfter:
  _dayjs:
    on:
      _state: date1
    operations:
      - - isAfter
        - _state: date2

Breaking Changes from v4

  • _moment renamed to _dayjs — simple find-and-replace in YAML config
  • thresholds parameter on humanizeDuration is accepted but ignored
  • Locale names are auto-normalized (e.g. en-USen)
  • 22 bundled locales; uncommon locales fall back to English