Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Unsupported lookbehind regex #160

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@origam/utils",
"main": "dist/index.js",
"version": "1.3.4",
"version": "1.3.5",
"license": "GPL-3.0",
"files": [
"dist"
Expand Down
9 changes: 7 additions & 2 deletions src/utils/dateConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ export function csToMomentFormat(csDateFormat: string | undefined) {
return null;
}
return csDateFormat // Meaning of the replaced character in c#:
.replace(/(?<!d)d(?!d)/g, "D") // The day of the month, from 1 through 31., do not replace "ddd" and "dddd" those are valid day of week symbols
.replace(/(?<!d)dd(?!d)/g, "DD")
// The day of the month, from 1 through 31., do not replace "ddd" and "dddd" those are valid day of week symbols
// Implemented by a replacement fn. due to Safari lack of negative lookbehind support.
.replace(/d+/g, (capturedString) =>
capturedString.length <= 2
? capturedString.replace(/d/g,'D')
: capturedString
)
.replace(/f/g, "S") // The tenths of a second in a date and time value.
.replace(/F/g, "S") // If non-zero, the tenths of a second in a date and time value.
.replace(/K/g, "Z") // time zone
Expand Down