Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 15, 2025

This pull request adds support for setting variables to the current date/time in the vsts-variable-set task, allowing users to specify a custom format for the date/time value. It also updates TypeScript build info files for both vsts-variable-set and vsts-variable-transform tasks to reflect the latest build.

New date/time variable feature

  • Added a new option "datetime": "current date/time" to the From pick list in vsts-variable-set/v3/task.json, enabling selection of the current date/time as a variable source.
  • Introduced a new input field DateTimeFormat in vsts-variable-set/v3/task.json for specifying the format of the date/time value, with help text describing supported patterns.
  • Implemented the formatDateTime function in vsts-variable-set/v3/vsts-variable-set.ts to replace format patterns (e.g., yyyy, MM, dd, HH, mm, ss, tt) with the corresponding values from the current date/time.
  • Updated the getValue function in vsts-variable-set/v3/vsts-variable-set.ts to handle the new "datetime" option and use the DateTimeFormat input for formatting.

Build info updates

  • Updated TypeScript build info files (tsconfig.tsbuildinfo) for all versions of vsts-variable-set and vsts-variable-transform to reflect the current build version. [1] [2]

@Copilot Copilot AI changed the title [WIP] Add the ability to format the current date and time according to a user provided format Add datetime formatting capability to variable set task Jul 15, 2025
Copilot finished work on behalf of jessehouwing July 15, 2025 12:12
@Copilot Copilot AI requested a review from jessehouwing July 15, 2025 12:12
@jessehouwing jessehouwing requested a review from Copilot September 2, 2025 16:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds datetime formatting capability to the variable set task, enabling users to set variables to the current date/time with custom formatting.

  • Added a new "datetime" option to the variable source picker with configurable format patterns
  • Implemented date/time formatting function supporting common patterns (yyyy, MM, dd, HH, mm, ss, tt)
  • Updated TypeScript build info files across multiple task versions

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

File Description
vsts-variable-set/v3/task.json Added "datetime" option to picker and new DateTimeFormat input field
vsts-variable-set/v3/vsts-variable-set.ts Implemented formatDateTime function and datetime case in getValue
vsts-variable-set/v*/tsconfig.tsbuildinfo Updated TypeScript build info to version 5.8.3
vsts-variable-transform/v*/tsconfig.tsbuildinfo Updated TypeScript build info to version 5.8.3

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}
case "datetime":
{
const format = tl.getInput("DateTimeFormat", true) || "yyyy-MM-dd HH:mm:ss";
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The 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
const format = tl.getInput("DateTimeFormat", true) || "yyyy-MM-dd HH:mm:ss";
const format = tl.getInput("DateTimeFormat", true);

Copilot uses AI. Check for mistakes.

formatted = formatted.replace(/HH/g, hour);

// Hour 12-hour patterns
const hour12 = (now.getHours() % 12 || 12).toString().padStart(2, '0');
Copy link

Copilot AI Sep 2, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants