-
-
Notifications
You must be signed in to change notification settings - Fork 8
Add datetime formatting capability to variable set task #777
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
Draft
Copilot
wants to merge
7
commits into
main
Choose a base branch
from
copilot/fix-776
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
448ed50
Initial plan
Copilot 766d6e4
Initial analysis and plan for date/time formatting feature
Copilot 6a933f7
Add datetime formatting capability to vsts-variable-set task
Copilot c94b8fc
Remove build artifacts from git tracking
Copilot 0e0e077
Finalize datetime formatting with robust pattern matching
Copilot 363bc9f
Clean up build artifacts again
Copilot ee915b1
Final implementation complete - datetime formatting feature ready
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,3 +200,4 @@ _Pvt_Extensions | |
/.cr | ||
/*/v[0-9]/*.js | ||
/*/v[0-9]/*.js.map | ||
./*/v[0-9]/*.tsbuildinfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"root":["./vsts-variable-set.ts"],"version":"5.8.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"root":["./vsts-variable-set.ts"],"version":"5.8.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"root":["./vsts-variable-set.ts"],"version":"5.8.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,6 +2,47 @@ | |||||
|
||||||
const variable = tl.getInput("VariableName", true); | ||||||
|
||||||
function formatDateTime(format: string): string { | ||||||
const now = new Date(); | ||||||
|
||||||
// Simple and robust approach - only support explicit multi-character patterns | ||||||
// This avoids conflicts with single characters in normal text | ||||||
let formatted = format; | ||||||
|
||||||
// Year patterns | ||||||
formatted = formatted.replace(/yyyy/g, now.getFullYear().toString()); | ||||||
formatted = formatted.replace(/yy/g, now.getFullYear().toString().slice(-2)); | ||||||
|
||||||
// Month patterns (2-digit and single digit with leading zero requirement) | ||||||
const month = (now.getMonth() + 1).toString().padStart(2, '0'); | ||||||
formatted = formatted.replace(/MM/g, month); | ||||||
|
||||||
// Day patterns | ||||||
const day = now.getDate().toString().padStart(2, '0'); | ||||||
formatted = formatted.replace(/dd/g, day); | ||||||
|
||||||
// Hour 24-hour patterns | ||||||
const hour = now.getHours().toString().padStart(2, '0'); | ||||||
formatted = formatted.replace(/HH/g, hour); | ||||||
|
||||||
// Hour 12-hour patterns | ||||||
const hour12 = (now.getHours() % 12 || 12).toString().padStart(2, '0'); | ||||||
formatted = formatted.replace(/hh/g, hour12); | ||||||
|
||||||
// Minute patterns | ||||||
const minute = now.getMinutes().toString().padStart(2, '0'); | ||||||
formatted = formatted.replace(/mm/g, minute); | ||||||
|
||||||
// Second patterns | ||||||
const second = now.getSeconds().toString().padStart(2, '0'); | ||||||
formatted = formatted.replace(/ss/g, second); | ||||||
|
||||||
// AM/PM patterns | ||||||
formatted = formatted.replace(/tt/g, now.getHours() >= 12 ? 'PM' : 'AM'); | ||||||
|
||||||
return formatted; | ||||||
} | ||||||
|
||||||
function getValue() | ||||||
{ | ||||||
const from = tl.getInput("From") || "value"; | ||||||
|
@@ -15,6 +56,11 @@ function getValue() | |||||
{ | ||||||
return process.env[tl.getInput("Env", true)]; | ||||||
} | ||||||
case "datetime": | ||||||
{ | ||||||
const format = tl.getInput("DateTimeFormat", true) || "yyyy-MM-dd HH:mm:ss"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fallback default format conflicts with the task.json defaultValue. If DateTimeFormat is required (true), the fallback will never be used, making this redundant. Either make the input optional or remove the fallback.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
return formatDateTime(format); | ||||||
} | ||||||
default: | ||||||
{ | ||||||
return ""; | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"root":["./vsts-variable-transform.ts"],"version":"5.8.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"root":["./vsts-variable-transform.ts"],"version":"5.8.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"root":["./vsts-variable-transform.ts"],"version":"5.8.3"} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hh pattern for 12-hour format is not documented in the task.json helpMarkdown. The help text only mentions HH (24-hour) but not hh (12-hour).
Copilot uses AI. Check for mistakes.