Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
384 stars 1.25k forks source link

timespan parameter #699

Closed MaameAJ closed 4 years ago

MaameAJ commented 5 years ago

There's no information on this page as to how to format the string in order to specify the format. There's no mention of a standard or link to a page to breakdown ' P3DT12H' what it means or what it is. I tried to google to see if this is any specific standard but was unable to find any helpful documentation. Please clarify the formatting of this string and what formatting this parameter is looking for.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

alexeldeib commented 5 years ago

@MaameAJ The parameter is an ISO8601 duration (https://en.wikipedia.org/wiki/ISO_8601#Durations). P3DT12H would be querying the [p]ast 3 days and 12 hours of data from the current datetime. The format is effectively:

P[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]

@tjprescott I recall when doing the App Insights extension, this was called out as not following best practice. I think the preferred method was start/stop/offset, like we did here. Is that accurate?

I can update the timespan implementation and bump the version + update docs. If this implementation is ok, I'll still PR a doc update.

tjprescott commented 5 years ago

@alexeldeib you could do something like start/stop/offset. It might also be just as adequate to use the azure.cli.core.commands.parameters.get_datetime_type helper, which will accept raw ISO 8601 or more user-friendly formats.

yonzhan commented 4 years ago

add to S172

mmyyrroonn commented 4 years ago

Closed this issue since it's a question and has been answered. Feel free to reopen it if you still encounter this issue.