Skip to content

Commit

Permalink
fix date functions
Browse files Browse the repository at this point in the history
  • Loading branch information
qiksar committed Dec 9, 2022
1 parent 80a5774 commit 89a7439
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@qiksar/crudio",
"version": "0.29.2",
"version": "0.29.3",
"description": "Rapidly create rich meaningful test data to accelerate your prototyping and testing processes",
"bin": "dist/cjs/crudio_cli.js",
"main": "dist/cjs/crudio_cli.js",
Expand Down
24 changes: 21 additions & 3 deletions src/CrudioDataModel.ts
Expand Up @@ -1453,15 +1453,33 @@ export default class CrudioDataModel {
if (generator_values.startsWith("years_ago_")) {
const years = parseInt(generator_values.replace("years_ago_", ""));

return DateTime.now()
.plus(years * -1)
const date = DateTime.now()
.plus({ years: years * -1 })
.toUTC()
.toString();

return date;
} else if (generator_values.startsWith("months_ago_")) {
const months = parseInt(generator_values.replace("months_ago_", ""));

return DateTime.now()
.plus(months * -1)
.plus({ months: months * -1 })
.toUTC()
.toString();
} else if (generator_values.startsWith("years_ahead_")) {
const years = parseInt(generator_values.replace("years_ago_", ""));

const date = DateTime.now()
.plus({ years: years })
.toUTC()
.toString();

return date;
} else if (generator_values.startsWith("months_ahead_")) {
const months = parseInt(generator_values.replace("months_ago_", ""));

return DateTime.now()
.plus({ months: months })
.toUTC()
.toString();
}
Expand Down

0 comments on commit 89a7439

Please sign in to comment.