Skip to content

Commit 6251796

Browse files
Merge pull request #1201 from ReliefApplications/next
Next
2 parents e2b1276 + 44eabce commit 6251796

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

CHANGELOG/CHANGELOG_next.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [2.14.0-rc.1](https://github.com/ReliefApplications/ems-backend/compare/v2.13.0...v2.14.0-rc.1) (2025-03-17)
2+
3+
4+
### Features
5+
6+
* enable {{now}} placeholder for datetime fields in edition ([#1200](https://github.com/ReliefApplications/ems-backend/issues/1200)) ([f97295b](https://github.com/ReliefApplications/ems-backend/commit/f97295b5b12d0c8bfb321bd33f5de0d8394cd1a0))
7+
18
# [2.13.0-rc.3](https://github.com/ReliefApplications/ems-backend/compare/v2.13.0-rc.2...v2.13.0-rc.3) (2025-03-04)
29

310

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ems-backend",
3-
"version": "2.13.0",
3+
"version": "2.14.0-rc.1",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

src/const/placeholders.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ export const isUsingTodayPlaceholder = (value: any) => {
3030
);
3131
};
3232

33+
/**
34+
* Tests whether value is using the {{now}} placeholder
35+
*
36+
* @param value value to test
37+
* @returns true if using {{now}}
38+
*/
39+
export const isUsingNowPlaceholder = (value: any) => {
40+
return value === Placeholder.NOW;
41+
};
42+
3343
/**
3444
* Extract string contained into brackets used for placeholders.
3545
*

src/utils/filter/getDateForMongo.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
REGEX_TODAY_PLUS,
44
REGEX_TODAY_MINUS,
55
isUsingTodayPlaceholder,
6+
isUsingNowPlaceholder,
67
} from '../../const/placeholders';
78

89
/**
@@ -17,6 +18,7 @@ export const getDateForMongo = (
1718
// today's date
1819
let startDate: Date;
1920
if (isUsingTodayPlaceholder(value)) {
21+
// Using {{today}}
2022
startDate = new Date();
2123
startDate.setHours(0, 0, 0, 0);
2224
// today + number of days
@@ -31,8 +33,12 @@ export const getDateForMongo = (
3133
extractStringFromBrackets(value).split('-')[1]
3234
);
3335
startDate.setDate(startDate.getDate() + difference);
34-
} // classic date
36+
}
37+
} else if (isUsingNowPlaceholder(value)) {
38+
// Using {{now}}
39+
startDate = new Date();
3540
} else {
41+
// Other dates
3642
startDate = new Date(value);
3743
}
3844
const endDate = new Date(startDate);

0 commit comments

Comments
 (0)