MicrosoftDocs / feedback

📢 docs.microsoft.com site feedback
https://learn.microsoft.com
Creative Commons Attribution 4.0 International
238 stars 160 forks source link

Azure Storage SDK for Javascript - date calculations are wrong #2748

Open drpritch opened 4 years ago

drpritch commented 4 years ago

Describe the bug Azure Storage SDK for Javascript documentation assumes Javascript dates are measured in seconds and that 24 hours = 86400, but they are actually measured in milliseconds, so 24 hours would be 86400000. The examples therefore don't work.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'https://docs.microsoft.com/en-us/javascript/api/@azure/storage-blob/?view=azure-node-latest'
  2. Scroll down to 'generateBlobSASQueryParameters'
  3. Drop that code sample into a node.js script. A client secret isn't required.
  4. The resulting SAS signature has an se= parameter that is only 35 seconds after the st parameter.

Expected behavior

Seen: st=2020-05-14T20%3A15%3A13Z&se=2020-05-14T20%3A16%3A40Z i.e., st = 2020-05-14 20:15:13 se = 2020-05-14 20:16:40

Expected: se = 2020-05-15 20:15:13

This is due to the input data, specifically the math in the expiresOn parameter. As shown: new Date().valueOf() + 86400

Should be: new Date().valueOf() + 86400000

I haven't scanned the documentation to see where else this is a problem, but it's probably pervasive.

Screenshots

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

welcome[bot] commented 4 years ago

Thank you for creating the issue! One of our team members will get back to you shortly with additional information. If this is a product issue, please close this and contact the particular product's support instead (see https://support.microsoft.com/allproducts for the list of support websites).

rootsmusic commented 3 years ago

@drpritch Please move this issue to https://github.com/MicrosoftDocs/azure-docs-sdk-node/issues