Добавлены конвертеры времени и url

This commit is contained in:
Pavel Gnedov 2022-07-25 11:36:06 +07:00
parent 1a65ab7fca
commit d833c68455
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,9 @@
/* eslint-disable @typescript-eslint/no-namespace */
export namespace TimestampConverter {
export function toTimestamp(date: string): number {
return new Date(date).getTime();
}
export function toString(date: number): string {
return new Date(date).toISOString();
}
}

View file

@ -0,0 +1,17 @@
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
@Injectable()
export class RedminePublicUrlConverter {
private redminePublicUrlPrefix: string;
constructor(private configService: ConfigService) {
this.redminePublicUrlPrefix = this.configService.get<string>(
'redmineIssueEventEmitterConfig.redmineUrlPublic',
);
}
convert(issueId: number | string): string {
return `${this.redminePublicUrlPrefix}/issues/${issueId}`;
}
}