[ADF-] update library to use new js-api 3.0.0 (#4097)

This commit is contained in:
Eugenio Romano
2019-01-06 23:57:01 +01:00
committed by Eugenio Romano
parent 2acd1b4e26
commit 3ef7d3b7ea
430 changed files with 1966 additions and 2149 deletions

29
e2e/util/dateUtil.ts Normal file
View File

@@ -0,0 +1,29 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* 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.
*/
import * as moment from 'moment';
export class DateUtil {
static formatDate(dateFormat: string, date: Date = new Date, days: number | string = 0): string {
return moment(date).add(days, 'days').format(dateFormat);
}
static parse(date: string, dateFormat: string = 'DD-MM-YY'): Date {
return moment(date, dateFormat).toDate();
}
}

View File

@@ -34,41 +34,6 @@ export class Util {
return path.resolve(path.join(parentFolder, filePath));
}
/**
* Get current date in long format: Oct 24, 2016
*
* @return {string}
* @method getCrtDateLongFormat
*/
static getCrtDateLongFormat() {
let currentDate = new Date();
let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
];
return months[currentDate.getMonth()] + ' ' + currentDate.getDate() + ', ' + (currentDate.getFullYear() + 1900);
}
/**
* Get current date in specified format
*
* @return {string}
* @method getCrtDateInFormat
*/
static getCrtDateInFormat(dateFormat) {
return moment().format(dateFormat);
}
/**
* Get specific date after current date in specific format
*
* @return {string}
* @method getCrtDateInFormat
*/
static getSpecificDateAfterCrtDateInFormat(dateFormat, days) {
return moment(new Date()).add(days, 'days').format(dateFormat);
}
/**
* Generates a random string.
*
@@ -214,10 +179,9 @@ export class Util {
/**
* Generates a random date inside the interval [1990, 2100) following the format dd.mm.yyyy
*
* @return {string}
* @method generateRandomDateFormat
*/
static generateRandomDateFormat() {
static generateRandomDateFormat(): string {
let day = Math.floor(Math.random() * (29 - 1) + 1);
let month = Math.floor(Math.random() * (12 - 1) + 1);
let year = Math.floor(Math.random() * (2100 - 1990) + 1990);
@@ -228,10 +192,9 @@ export class Util {
/**
* Generates a random date inside the interval [1990, 2100) following the format dd-mm-yyyy.
*
* @return {string}
* @method generateRandomDate
*/
static generateRandomDate() {
static generateRandomDate(): string {
let dayText, monthText;
let day = (Math.floor(Math.random() * (29 - 1) + 1));
@@ -256,7 +219,7 @@ export class Util {
* @return {boolean}
* @method arrayContainsArray
*/
static arrayContainsArray(superset, subset) {
static arrayContainsArray(superset: any[], subset: any[]) {
if (0 === subset.length) {
return false;
}