Description
When I'm using the planner task add command with --startDateTime option in PowerShell, I always get following error:
Error: The startDateTime is not a valid ISO date string
I'm using PowerShell, passing startDateTime like this:
m365 planner task add --planId $planId --title "Test" --startDateTime $date.ToString("o")
Using .ToString("o") is a proper way to retrieve an ISO string in PowerShell/C#. The docs are stating this is a valid ISO 8601 format.

This outputs the date in following format: 2021-12-16T18:28:48.6964197Z.
When I look at the code you can see that only 3 milliseconds digits are considered valid.
|
isValidISODateTime(dateTime: string): boolean { |
|
const withMilliSecsPattern: RegExp = new RegExp( |
|
/^[0-9]{4}-((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01])|(0[469]|11)-(0[1-9]|[12][0-9]|30)|(02)-(0[1-9]|[12][0-9]))T(0[0-9]|1[0-9]|2[0-3]):(0[0-9]|[1-5][0-9]):(0[0-9]|[1-5][0-9])\.[0-9]{3}Z$/); |
|
if (withMilliSecsPattern.test(dateTime)) { |
|
return true; |
|
} |
This is the reason why the command results in an error message. An ISO string with 7 milliseconds digits is considered as invalid. This shouldn't be the case, an ISO string with 7 milliseconds digits is valid. After changing the code, it works perfectly.

As you can see, the result output has 7 milliseconds digits as well for createdDateTime.
Apart from that, when you check the docs of this command, you can see that the options --startDateTime and --endDateTime show an example of a date with 7 milliseconds digits. So when you use the examples from the docs, you'll receive an error message saying the date is invalid.


Steps to reproduce
Use any command with a date validation e.g. planner task add and specify a date string with 7 milliseconds digits.
Example:
m365 planner task add --planId "Isp_70BV1kOJ6rilI8NPi5cAHFre" --title "test" --bucketName "To do" --startDateTime "2021-12-16T18:28:48.6964197Z"
Expected results
The command should accept the input and execute.
Actual results
Error: The startDateTime is not a valid ISO date string
Diagnostics
No response
CLI for Microsoft 365 version
v5.3.0
nodejs version
v16.11.1
Operating system (environment)
Windows
Shell
Windows PowerShell
cli doctor
No response
Additional Info
I suggest that we add an extra validation rule so both date strings with 3 and 7 milliseconds digits are valid.
Description
When I'm using the
planner task addcommand with--startDateTimeoption in PowerShell, I always get following error:I'm using PowerShell, passing
startDateTimelike this:Using

.ToString("o")is a proper way to retrieve an ISO string in PowerShell/C#. The docs are stating this is a valid ISO 8601 format.This outputs the date in following format:
2021-12-16T18:28:48.6964197Z.When I look at the code you can see that only 3 milliseconds digits are considered valid.
cli-microsoft365/src/utils/validation.ts
Lines 56 to 61 in 694dbc5
This is the reason why the command results in an error message. An ISO string with 7 milliseconds digits is considered as invalid. This shouldn't be the case, an ISO string with 7 milliseconds digits is valid. After changing the code, it works perfectly.
As you can see, the result output has 7 milliseconds digits as well for
createdDateTime.Apart from that, when you check the docs of this command, you can see that the options
--startDateTimeand--endDateTimeshow an example of a date with 7 milliseconds digits. So when you use the examples from the docs, you'll receive an error message saying the date is invalid.Steps to reproduce
Use any command with a date validation e.g.
planner task addand specify a date string with 7 milliseconds digits.Example:
Expected results
The command should accept the input and execute.
Actual results
Error: The startDateTime is not a valid ISO date string
Diagnostics
No response
CLI for Microsoft 365 version
v5.3.0
nodejs version
v16.11.1
Operating system (environment)
Windows
Shell
Windows PowerShell
cli doctor
No response
Additional Info
I suggest that we add an extra validation rule so both date strings with 3 and 7 milliseconds digits are valid.