How can we help?
Use dates and times
Tests that involve dates and times or have a behavior dependent on a date can be tricky. Trudon allows you to easily create a step that will generate a date or time according to predefined properties. Such behavior can be used in action steps (ex: setting a value in an input) or expectations.
Before using dates and times in your tests, I suggest you first play with the built-in variables, as it is quite similar.
In order to integrate the date/time feature offered by Trudon, you can edit any step from the test details or the test run details using the following format:
{{ date 'REFERANCE_DAY' 'DATETIME_FORMAT' }}
Here are some examples:
{{date '5 years ago' 'MMMM Do YYYY, h:mm:ss a'}}translates to:November 10th 2015, 7:57:48 pm{{date 'yesterday' 'MMM Do YY'}}translates to:Nov 10th 20{{date 'today' 'dddd'}}translates to:Tuesday{{date 'in 2 days' 'dddd, DD MMM'}}translates to:Friday, 13 Nov
How to format the reference day
You should pass a human-readable date phrase. Check the following examples:
- today, now
- yesterday, tomorrow
- 2 years ago, in 2 years
- 2 months ago, in 2 months
- 2 weeks ago, in 2 weeks
- 2 days ago, in 2 days
- 2 hours ago, in 2 hours
- 2 minutes ago, in 2 minutes
How to format the date/time
Trudon offers a robust way to format your date times. It takes a string of tokens and replaces them with their corresponding values. A few examples:
dddd, MMMM Do YYYY, h:mm:sstranslates to:Sunday, February 14th 2010, 3:25:50ddd, hAtranslates to:Sun, 3PM[Today is] ddddtranslates to:Today is Sunday
A list of all available tokens that can be combined in any combination you might need can be checked in the table below.
| Token | Output | |
| Month | M | 1 2 ... 11 12 |
| Mo | 1st 2nd … 11th 12th | |
| MM | 01 02 … 11 12 | |
| MMM | Jan Feb … Nov Dec | |
| MMMM | January February … November December | |
| Quarter | Q | 1 2 3 4 |
| Qo | 1st 2nd 3rd 4th | |
| Day of month | D | 1 2 ... 30 31 |
| Do | 1st 2nd ... 30th 31st | |
| DD | 01 02 ... 30 31 | |
| Day of year | DDD | 1 2 … 364 365 |
| DDDo | 1st 2nd … 364th 365th | |
| DDDD | 001 002 … 364 365 | |
| Day of week | d | 0 1 ... 5 6 |
| do | 0th 1st … 5th 6th | |
| dd | Su Mo … Fr Sa | |
| ddd | Sun Mon … Fri Sat | |
| dddd | Sunday Monday … Friday Saturday | |
| Week of year | W | 1 2 … 52 53 |
| Wo | 1st 2nd … 52nd 53rd | |
| WW | 01 02 … 52 53 | |
| Year | YY | 70 71 … 29 30 |
| YYYY | 1970 1971 … 2029 2030 | |
| AM/PM | A | AM PM |
| a | am pm | |
| Hour | H | 0 1 … 22 23 |
| HH | 00 01 … 22 23 | |
| h | 1 2 … 11 12 | |
| hh | 01 02 … 11 12 | |
| k | 1 2 … 23 24 | |
| kk | 01 02 … 23 24 | |
| Minute | m | 0 1 … 58 59 |
| mm | 00 01 ... 58 59 | |
| Second | s | 0 1 … 58 59 |
| ss | 00 01 ... 58 59 |
To escape characters in format strings, you can wrap the characters in square brackets:
[today is] ddddtranslates to:today is Friday
