Skip to content

Commit

Permalink
Merge pull request #77 from uatisdeproblem/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
uatisdeproblem authored Feb 12, 2024
2 parents 98232f6 + 7202c25 commit 07d8545
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 27 deletions.
4 changes: 2 additions & 2 deletions back-end/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion back-end/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.3",
"version": "1.8.4",
"name": "back-end",
"scripts": {
"lint": "eslint --ext .ts",
Expand Down
2 changes: 1 addition & 1 deletion back-end/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.3

info:
title: ESN Assembly app
version: 1.8.3
version: 1.8.4
contact:
name: Matteo Carbone
email: [email protected]
Expand Down
4 changes: 2 additions & 2 deletions front-end/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion front-end/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esn-assembly",
"version": "1.8.3",
"version": "1.8.4",
"author": "Matteo Carbone",
"homepage": "https://matteocarbone.com/",
"scripts": {
Expand Down
50 changes: 33 additions & 17 deletions front-end/src/app/common/dateTimezone.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,38 @@ export class DateTimezonePipe implements PipeTransform {
constructor(private t: IDEATranslationsService, private app: AppService) {}

transform(value: any, pattern: 'date' | 'datetime' | 'time' = 'date', timezone?: string): string | null {
if (!value) return null;
const d = new Date(value);
const lang = this.t.getCurrentLang();
const options = { timeZone: timezone ?? this.app.configurations.timezone };
if (pattern === 'datetime')
return d.toLocaleString(lang, {
...options,
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
hour12: false
});
if (pattern === 'time')
return d.toLocaleTimeString(lang, { ...options, hour: 'numeric', minute: 'numeric', hour12: false });
else return d.toLocaleDateString(lang, { ...options, year: 'numeric', month: 'short', day: '2-digit' });
return formatDateWithLocaleAndTimeZone(
value,
this.t.getCurrentLang(),
timezone ?? this.app.configurations.timezone,
pattern
);
}
}

/**
* Transform a date with a locale and a timezone in the app's standard.
*/
export const formatDateWithLocaleAndTimeZone = (
value: any,
locale: string,
timeZone: string,
pattern: 'date' | 'datetime' | 'time' = 'date'
): string | null => {
if (!value) return null;
const d = new Date(value);
const options = { timeZone };
if (pattern === 'datetime')
return d.toLocaleString(locale, {
...options,
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
hour12: false
});
if (pattern === 'time')
return d.toLocaleTimeString(locale, { ...options, hour: 'numeric', minute: 'numeric', hour12: false });
return d.toLocaleDateString(locale, { ...options, year: 'numeric', month: 'short', day: '2-digit' });
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IonicModule } from '@ionic/angular';
import { isToday, isTomorrow } from 'date-fns';
import { IDEATranslationsModule, IDEATranslationsService } from '@idea-ionic/common';

import { DateTimezonePipe } from '@common/dateTimezone.pipe';
import { DateTimezonePipe, formatDateWithLocaleAndTimeZone } from '@common/dateTimezone.pipe';

import { AppService } from '@app/app.service';

Expand Down Expand Up @@ -99,6 +99,6 @@ export class DeadlineComponent {
const date = new Date(this.deadline.at);
if (isToday(date)) return this.t._('DEADLINES.TODAY');
if (isTomorrow(date)) return this.t._('DEADLINES.TOMORROW');
else return this.t.formatDate(date);
else return formatDateWithLocaleAndTimeZone(date, this.t.getCurrentLang(), this.app.configurations.timezone);
}
}
2 changes: 1 addition & 1 deletion front-end/src/environments/environment.idea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const STAGE = 'prod';
*/
export const environment = {
idea: {
app: { version: '1.8.3', mediaUrl: 'https://'.concat(parameters.mediaDomain), maxFileUploadSizeMB: 50 },
app: { version: '1.8.4', mediaUrl: 'https://'.concat(parameters.mediaDomain), maxFileUploadSizeMB: 50 },
api: { url: parameters.apiDomain, stage: STAGE },
socket: { url: parameters.webSocketApiDomain, stage: STAGE },
ionicExtraModules: ['common']
Expand Down

0 comments on commit 07d8545

Please sign in to comment.