A Yaak plugin that provides Day.js date/time manipulation functions as template functions for API testing and development.
This plugin extends Yaak with powerful date/time manipulation capabilities using Day.js, a lightweight alternative to Moment.js.
Converts dates to ISO format or UTC JSON format.
Parameters:
dateTime(optional): Base date/time string. Leave empty for current date/timetoUTCTime(optional): Convert to UTC format
Examples:
{{dayjs()}}- Current date/time in local format{{dayjs("2024-01-15")}}- Specific date in local format{{dayjs("2024-01-15", true)}}- Specific date in UTC format
Formats dates using custom format strings.
Parameters:
dateTime: Base date/time stringformat: Format pattern (optional, defaults to "YYYY-MM-DD HH:mm:ss")
Examples:
{{dayjs.format("2024-01-15T12:00:00", "MMM DD, YYYY")}}- "Jan 15, 2024"{{dayjs.format("2024-01-15T12:00:00", "dddd, MMMM Do YYYY")}}- "Monday, January 15th 2024"
Shows relative time from one date to another.
Parameters:
dateTime: Target date/timefromDate: Reference date/time
Examples:
{{dayjs.from("2024-01-15", "2024-01-10")}}- "5 days ago"{{dayjs.from("2024-02-01", "2024-01-01")}}- "in a month"
Converts dates to ISO 8601 string format.
Parameters:
dateTime: Date/time string to convert
Examples:
{{dayjs.toISOString("2024-01-15T12:00:00")}}- "2024-01-15T12:00:00.000Z"
- Download the plugin from the releases page
- Open Yaak and go to Settings → Plugins
- Install the plugin by selecting the downloaded file
Use the template functions anywhere in your HTTP requests:
POST {{baseUrl}}/api/events
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"created_at": "{{dayjs()}}",
"formatted_date": "{{dayjs.format("2024-01-15", "MMM DD, YYYY")}}",
"relative_time": "{{dayjs.from("2024-01-15", "2024-01-10")}}"
}
The plugin automatically validates input dates. If an invalid date is provided, it will:
- Display an "Invalid Date" error message in Yaak
- Still attempt to process the request (for backward compatibility)
This plugin includes the following Day.js plugins:
- UTC: Time zone manipulation
- Relative Time: Human-readable time differences
- Advanced Format: Extended formatting options
- Duration: Time duration calculations
- Localized Format: Locale-aware formatting
| Pattern | Example Output | Description |
|---|---|---|
YYYY-MM-DD |
2024-01-15 | ISO date |
HH:mm:ss |
14:30:45 | 24-hour time |
MMM DD, YYYY |
Jan 15, 2024 | Short date |
dddd, MMMM Do YYYY |
Monday, January 15th 2024 | Full date |
YYYY-MM-DDTHH:mm:ss.SSSZ |
2024-01-15T14:30:45.123Z | ISO datetime |
- Node.js >= 18
- pnpm
git clone https://github.com/aleksanderwalczuk/yaak-dayjs-plugin.git
cd yaak-dayjs-plugin
pnpm installpnpm buildpnpm testpnpm lint
pnpm lint:fix- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite:
pnpm test - Submit a pull request
UNLICENSED
Aleksander Walczuk - ohleg@windowslive.com