Example #1
0
 export function toFormatter(date: Date): DateFormatter {
     const wrappedDate = dayjs(date);
     return {
         fromNow: () => wrappedDate.fromNow(),
         format: (format: string) => wrappedDate.format(format)
     };
 }
Example #2
0
gulp.task('clean:version-lib', (next) => {
    const v = npmconfig.version;
    const b = dayjs().startOf('m').valueOf();
    return gulp.src(['./lib/src/composer.module.ts']) // Any file globs are supported
        .pipe(replace(/public static version = '[0-9a-zA-Z.-]*'/g, `public static version = 'local-dev'`, { logs: { enabled: true } }))
        .pipe(replace(/private build = dayjs\([0-9]*\);/g, `private build = dayjs();`, { logs: { enabled: true } }))
        .pipe(gulp.dest('./lib/src'));
});
Example #3
0
gulp.task('update:version', (next) => {
    const v = npmconfig.version;
    const b = dayjs().startOf('m').valueOf();
    return gulp.src(['./src/app/services/settings.service.ts']) // Any file globs are supported
        .pipe(replace(/this.log\('SYSTEM', 'Version: [0-9a-zA-Z.-]*'/g, `this.log('SYSTEM', 'Version: ${v}'`, { logs: { enabled: true } }))
        .pipe(replace(/const built = dayjs\([0-9]*\);/g, `const built = dayjs(${b});`, { logs: { enabled: true } }))
        .pipe(gulp.dest('./src/app/services'));
});
Example #4
0
export const downloadJSON = (panelName, modelName, endpoint) => {
	const timestamp = dayjs(Date.now()).format('DD_MM_YYYY_HH_mm_ss');

	return api.get(endpoint).then((res) => {
		const content = JSON.stringify(res.data, null, 2);
		const a = document.createElement('a');
		const file = new Blob([content]);
		a.href = URL.createObjectURL(file);
		a.download = `${modelName}_${timestamp}_${panelName}.json`;
		document.body.appendChild(a);
		a.click();
		document.body.removeChild(a);
	});
};
Example #5
0
export function reviver(key, value) {
  if (typeof value === 'string')
    if (ISO8601Regex.exec(value))
      return dayjs(value).toDate();
  return value;
}
Example #6
0
export function replacer(key, value) {
  if (typeof value === 'string')
    if (ISO8601Regex.exec(value))
      return dayjs(value).format("YYYY-MM-DDTHH:mm:ss.SSSZ");
  return value;
}
Example #7
0
 export function getFormatter(date: Date): DateFormatter {
     return dayjs(date);
 }