Skip to content

Commit

Permalink
fix: timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
tassyla committed Oct 20, 2024
1 parent efbef64 commit cdaa3af
Show file tree
Hide file tree
Showing 4 changed files with 3,052 additions and 3,530 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"express-async-errors": "^3.1.1",
"handlebars": "^4.7.7",
"jsonwebtoken": "^9.0.2",
"moment": "^2.30.1",
"moment-timezone": "^0.5.46",
"multer": "^1.4.5-lts.1",
"nodemailer": "^6.4.18",
"openapi-types": "^10.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/modules/users/services/CreateAppointmentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Users } from '@prisma/client';
import AppError from '@shared/errors/AppError';

import IUsersRepository from '../repositories/IUsersRepository';
import moment from 'moment';
import moment from 'moment-timezone';

interface IRequest {
id: string;
Expand All @@ -25,8 +25,8 @@ export default class CreateAppointmentService {
const user = await this.usersRepository.findById(id);
if (!user) throw new AppError('This user does not exist');

const formattedDate = moment().locale('pt-br').format('DD/MM/YYYY');
const formattedTime = moment().locale('pt-br').format('HH:mm');
const formattedDate = moment().tz("America/Sao_Paulo").format('DD/MM/YYYY');
const formattedTime = moment().tz("America/Sao_Paulo").format('HH:mm');
const formattedBirthdate = moment(user.birthdate, 'DD/MM/YYYY').locale('pt-br').format('DD/MM/YYYY');

sgMail.setApiKey(process.env.SENDGRID_API_KEY as string);
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"lib": ["ES2015", "DOM"],
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
Expand Down
Loading

0 comments on commit cdaa3af

Please sign in to comment.