summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-01-28 12:28:30 +0100
committerVincent Petry <pvince81@owncloud.com>2016-01-28 15:25:34 +0100
commit7e1de0e3c29d79ba37b6ab911c398eda0aff57ca (patch)
tree3e1b34bbd83fe33fd3774676ccf011e66c22a096 /core
parentb063ddb05b71988d92fe140ca003ad58301cfcc8 (diff)
downloadnextcloud-server-7e1de0e3c29d79ba37b6ab911c398eda0aff57ca.tar.gz
nextcloud-server-7e1de0e3c29d79ba37b6ab911c398eda0aff57ca.zip
Fix share default expiration date calculation
Now using UTC dates with moment js to accurately add the number of days
Diffstat (limited to 'core')
-rw-r--r--core/js/shareconfigmodel.js13
-rw-r--r--core/js/tests/specs/shareitemmodelSpec.js4
2 files changed, 8 insertions, 9 deletions
diff --git a/core/js/shareconfigmodel.js b/core/js/shareconfigmodel.js
index 64f18558267..5494feaf7fa 100644
--- a/core/js/shareconfigmodel.js
+++ b/core/js/shareconfigmodel.js
@@ -8,6 +8,8 @@
*
*/
+/* global moment */
+
(function() {
if (!OC.Share) {
OC.Share = {};
@@ -73,13 +75,10 @@
getDefaultExpirationDateString: function () {
var expireDateString = '';
if (this.get('isDefaultExpireDateEnabled')) {
- var date = new Date().getTime();
- var expireAfterMs = this.get('defaultExpireDate') * 24 * 60 * 60 * 1000;
- var expireDate = new Date(date + expireAfterMs);
- var month = expireDate.getMonth() + 1;
- var year = expireDate.getFullYear();
- var day = expireDate.getDate();
- expireDateString = year + "-" + month + '-' + day + ' 00:00:00';
+ var date = moment.utc();
+ var expireAfterDays = this.get('defaultExpireDate');
+ date.add(expireAfterDays, 'days');
+ expireDateString = date.format('YYYY-MM-DD 00:00:00');
}
return expireDateString;
}
diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js
index d696b159e47..e1a14bbbe7f 100644
--- a/core/js/tests/specs/shareitemmodelSpec.js
+++ b/core/js/tests/specs/shareitemmodelSpec.js
@@ -634,8 +634,8 @@ describe('OC.Share.ShareItemModel', function() {
password: '',
passwordChanged: false,
permissions: OC.PERMISSION_READ,
- expireDate: '2015-7-24 00:00:00',
- shareType: OC.Share.SHARE_TYPE_LINK
+ expireDate: '2015-07-24 00:00:00',
+ shareType: OC.Share.SHARE_TYPE_LINK
});
expect(updateShareStub.notCalled).toEqual(true);
clock.restore();