Add relative time and date #6

Merged
stne3960 merged 5 commits from relative_dates into main 2025-11-03 23:38:56 +01:00
Owner

Adding the ability to set relative times and dates to be returned. See documentation: https://gitea.dsv.su.se/DMC/apimposter/src/branch/relative_dates#format-specifiers-optional

How do test

You can test using the following yaml-file:

- method: "GET"
  path: "/"
  response:
    status: 200
    headers:
      Content-Type: "application/json"
    body:
      description: "Relative date/time placeholder examples"
      # ISO formats (default)
      currentTime: "{datetime+0d@08:00}"
      today: "{date+0d}"
      tomorrow: "{date+1d}"
      futureDateTime: "{datetime+2d4h30m}"
      pastDateTime: "{datetime-1d@15:30}"
      # RFC3339 formats
      currentTimeRfc: "{datetime+0d@08:00:rfc3339}"
      tomorrowRfc: "{datetime+1d@13:00:rfc3339}"
      # Custom formats
      todayCustom: "{date+0d:MMM dd, yyyy}"
      tomorrowCustom: "{date+1d:EEEE, MMMM d}"
      futureCustom: "{datetime+1d@15:30:yyyy-MM-dd HH:mm:ss}"
      timeOnly: "{datetime+0d@14:30:HH:mm:ss}"

- method: "GET"
  path: "/examples"
  response:
    status: 200
    headers:
      Content-Type: "application/json"
    body:
      calendar:
        - event: "Morning standup"
          time: "{datetime+1d@09:00}"
          date: "{date+1d:EEEE, MMM dd}"
        - event: "Client meeting"
          time: "{datetime+2d@14:30:rfc3339}"
          date: "{date+2d}"
        - event: "Weekly review"
          time: "{datetime+7d@16:00}"
          date: "{date+7d:MMM dd, yyyy}"
Adding the ability to set relative times and dates to be returned. See documentation: https://gitea.dsv.su.se/DMC/apimposter/src/branch/relative_dates#format-specifiers-optional ## How do test You can test using the following yaml-file: ```yml - method: "GET" path: "/" response: status: 200 headers: Content-Type: "application/json" body: description: "Relative date/time placeholder examples" # ISO formats (default) currentTime: "{datetime+0d@08:00}" today: "{date+0d}" tomorrow: "{date+1d}" futureDateTime: "{datetime+2d4h30m}" pastDateTime: "{datetime-1d@15:30}" # RFC3339 formats currentTimeRfc: "{datetime+0d@08:00:rfc3339}" tomorrowRfc: "{datetime+1d@13:00:rfc3339}" # Custom formats todayCustom: "{date+0d:MMM dd, yyyy}" tomorrowCustom: "{date+1d:EEEE, MMMM d}" futureCustom: "{datetime+1d@15:30:yyyy-MM-dd HH:mm:ss}" timeOnly: "{datetime+0d@14:30:HH:mm:ss}" - method: "GET" path: "/examples" response: status: 200 headers: Content-Type: "application/json" body: calendar: - event: "Morning standup" time: "{datetime+1d@09:00}" date: "{date+1d:EEEE, MMM dd}" - event: "Client meeting" time: "{datetime+2d@14:30:rfc3339}" date: "{date+2d}" - event: "Weekly review" time: "{datetime+7d@16:00}" date: "{date+7d:MMM dd, yyyy}" ```
stne3960 added 2 commits 2025-09-10 13:59:30 +02:00
Add relative date and time
Some checks failed
Build, Test & Checkstyle / build (push) Failing after 59s
d18914e699
Fix checkstyle errors
All checks were successful
Build, Test & Checkstyle / build (push) Successful in 56s
ba6817390c
ansv7779 approved these changes 2025-09-12 11:30:28 +02:00
ansv7779 left a comment
Owner

Looks good.

It would be possible to use group names in the patterns instead of numbered. May help with understandability of the long patterns.

Looks good. It would be possible to use [group names](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/regex/Pattern.html#groupname) in the patterns instead of numbered. May help with understandability of the long patterns.
stne3960 added 1 commit 2025-11-03 23:20:19 +01:00
Use more descriptive group constants
All checks were successful
Build, Test & Checkstyle / build (push) Successful in 1m13s
e75826acca
stne3960 added 2 commits 2025-11-03 23:36:30 +01:00
stne3960 merged commit 1b29aeb4f6 into main 2025-11-03 23:38:56 +01:00
stne3960 deleted branch relative_dates 2025-11-03 23:38:56 +01:00
Sign in to join this conversation.
No Reviewers
No Label
No Milestone
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DMC/apimposter#6
No description provided.