mirror of
https://github.com/nextcloud/server.git
synced 2024-08-30 17:57:26 +02:00
Fix share default expiration date calculation
Now using UTC dates with moment js to accurately add the number of days
This commit is contained in:
parent
b063ddb05b
commit
7e1de0e3c2
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user