This is a small tool that converts hardcoded dates written in DBUnit XML files, to relative dates using the [now+ny+nM+nd] syntax.
The tool scans for dates in the following formats:
- "YYYY-MM-DD"
- "YYYY-MM-DD HH:MM:SS"
- "YYYY-MM-DD HH:MM:SS.F"
Clone the repo and navigate to the directory in the terminal. To execute the script run the command below:
python main.py \path\to\test\resources\directory\or\file.xmlBelow are the additional optional arguments for the command:
| Option | Default | Description |
|---|---|---|
| -o / --output [OUTPUT] | "" | This allows for a different output directory to be specified for the converted files. The original files will not be modified. |
| --dry-run | False | This flag allows you to check the output of the script without saving the results. The resulting file contents will be output once the script has finished executing. |
The tool separates historic and future dates and finds the closest date in each to the present day. It then sets this to a relative value of + or - 1 year (depending on whether it was a historic or future date). The offset between the original date and the new date is calculated and applied to the rest of the dates in their respective groups.