[APPS-2108] break direct dependency on moment.js (#9032)

* break direct dependency on moment.js

* [ci:force] preserve moment for cli tools

* remove MatMomentDatetimeModule from content

* share dialog fixes

* revert testing module changes

* remove incorrect date modules

* fix html
This commit is contained in:
Denys Vuika
2023-10-26 14:33:26 +01:00
committed by GitHub
parent abf369bc37
commit 7ebdce7875
25 changed files with 82 additions and 160 deletions

View File

@@ -17,9 +17,13 @@
import { Injectable } from '@angular/core';
import { DateAdapter } from '@angular/material/core';
import moment, { isMoment, Moment } from 'moment';
import { UserPreferencesService, UserPreferenceValues } from '../services/user-preferences.service';
// Stub for the moment.js integration.
// While this dependency is no longer used by the libraries, the moment adapter can still discover the moment.js linked to the application
declare let moment: any;
type Moment = any;
/**
* @deprecated this class is deprecated and should not be used.
* Consider using `AdfDateFnsAdapter` or `AdfDateTimeFnsAdapter` instead
@@ -183,7 +187,7 @@ export class MomentDateAdapter extends DateAdapter<Moment> {
if (first == null) {
// same if both null
return second == null;
} else if (isMoment(first)) {
} else if (moment.isMoment(first)) {
return first.isSame(second);
} else {
const isSame = super.sameDate(first, second);

View File

@@ -16,14 +16,15 @@
*/
import { Pipe, PipeTransform } from '@angular/core';
import moment, { Moment } from 'moment';
declare let moment: any;
/**
* @deprecated this pipe is deprecated and should no longer be used
*/
@Pipe({ name: 'adfMomentDate' })
export class MomentDatePipe implements PipeTransform {
transform(value: moment.MomentInput, dateFormat: string): Moment {
transform(value: any, dateFormat: string): any {
return moment(value, dateFormat);
}
}

View File

@@ -16,17 +16,14 @@
*/
import { Pipe, PipeTransform } from '@angular/core';
import moment, { Moment } from 'moment';
declare let moment: any;
/**
* @deprecated this pipe is deprecated and should no longer be used
*/
@Pipe({ name: 'adfMomentDateTime' })
export class MomentDateTimePipe implements PipeTransform {
transform(value: moment.MomentInput, dateFormat: string): Moment {
return moment(value, dateFormat)
.add(
moment(value, dateFormat).utcOffset(),
'minutes');
transform(value: any, dateFormat: string): any {
return moment(value, dateFormat).add(moment(value, dateFormat).utcOffset(), 'minutes');
}
}