This repository has been archived by the owner on May 5, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #564 from andrerod/dev
#499: Make generating blob URL with SAS easier
- Loading branch information
Showing
11 changed files
with
207 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,62 @@ | |||
/** | |||
* Copyright (c) Microsoft. All rights reserved. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
/** | |||
* Generates a Date object which is in the given days from now. | |||
* | |||
* @param {int} days The days timespan. | |||
* @return {Date} | |||
*/ | |||
exports.daysFromNow = function (days) { | |||
var date = new Date() | |||
date.setDate(date.getDate() + days); | |||
return date; | |||
}; | |||
|
|||
/** | |||
* Generates a Date object which is in the given hours from now. | |||
* | |||
* @param {int} hours The hours timespan. | |||
* @return {Date} | |||
*/ | |||
exports.hoursFromNow = function (hours) { | |||
var date = new Date() | |||
date.setHours(date.getHours() + hours); | |||
return date; | |||
}; | |||
|
|||
/** | |||
* Generates a Date object which is in the given minutes from now. | |||
* | |||
* @param {int} minutes The minutes timespan. | |||
* @return {Date} | |||
*/ | |||
exports.minutesFromNow = function (minutes) { | |||
var date = new Date() | |||
date.setMinutes(date.getMinutes() + minutes); | |||
return date; | |||
}; | |||
|
|||
/** | |||
* Generates a Date object which is in the given seconds from now. | |||
* | |||
* @param {int} seconds The seconds timespan. | |||
* @return {Date} | |||
*/ | |||
exports.secondsFromNow = function (seconds) { | |||
var date = new Date() | |||
date.setSeconds(date.getSeconds() + seconds); | |||
return date; | |||
}; |
This file contains 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 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 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,58 @@ | |||
/** | |||
* Copyright (c) Microsoft. All rights reserved. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
var should = require('should'); | |||
var sinon = require('sinon'); | |||
|
|||
var testutil = require('./util'); | |||
var azure = testutil.libRequire('azure'); | |||
|
|||
suite('date-tests', function () { | |||
setup(function () { | |||
this.clock = sinon.useFakeTimers(0, "Date"); | |||
}); | |||
|
|||
teardown(function () { | |||
this.clock.restore(); | |||
}); | |||
|
|||
test('daysFromNow', function () { | |||
var daysInterval = 1; | |||
var expectedDate = new Date('Jan 2, 1970 00:00:00 am GMT'); | |||
|
|||
azure.date.daysFromNow(daysInterval).should.equal(expectedDate); | |||
}); | |||
|
|||
test('hoursFromNow', function () { | |||
var hoursInterval = 3; | |||
var expectedDate = new Date('Jan 1, 1970 03:00:00 am GMT'); | |||
|
|||
azure.date.hoursFromNow(hoursInterval).should.equal(expectedDate); | |||
}); | |||
|
|||
test('minutesFromNow', function () { | |||
var minutesInterval = 10; | |||
var expectedDate = new Date('Jan 1, 1970 00:10:00 am GMT'); | |||
|
|||
azure.date.minutesFromNow(minutesInterval).should.equal(expectedDate); | |||
}); | |||
|
|||
test('secondsFromNow', function () { | |||
var secondsInterval = 20; | |||
var expectedDate = new Date('Jan 1, 1970 00:00:20 am GMT'); | |||
|
|||
azure.date.secondsFromNow(secondsInterval).should.equal(expectedDate); | |||
}); | |||
}); |