From fbe452612fe18db1eb0f674f02d8f725891d608f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= Date: Thu, 9 Jan 2025 23:13:48 +0100 Subject: [PATCH] fix: moment timezone --- package.json | 5 +- prisma/schema.prisma | 8 +-- src/modules/class/class.service.ts | 4 +- src/modules/class/dto/create-room.dto.ts | 4 +- yarn.lock | 83 +++++++++++++----------- 5 files changed, 57 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index 45d9b5b..305460d 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@nestjs/platform-socket.io": "^10.4.12", "@nestjs/swagger": "^8.0.7", "@nestjs/websockets": "^10.4.12", - "@prisma/client": "^6.1.0", + "@prisma/client": "^6.2.1", "axios": "^1.7.7", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", @@ -37,8 +37,9 @@ "jsonwebtoken": "^9.0.2", "jwks-rsa": "^3.1.0", "moment": "^2.30.1", + "moment-timezone": "^0.5.46", "nestjs-prisma": "^0.23.0", - "prisma": "^6.1.0", + "prisma": "^6.2.1", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1", "socket.io": "^4.8.1" diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 3e7e8a8..284d86f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -44,7 +44,7 @@ model Class { model Room { id String @id @default(cuid()) name String - date DateTime + date DateTime @db.Date Presentator User @relation("Presentator", fields: [presentatorId], references: [id]) presentatorId String @@ -57,8 +57,8 @@ model Room { model RoomTime { id Int @id @default(autoincrement()) - startTime DateTime - endTime DateTime + startTime DateTime @db.Time + endTime DateTime @db.Time Room Room @relation(fields: [roomId], references: [id], onDelete: Cascade) roomId String } @@ -103,4 +103,4 @@ model RoomSurveyAnswerUser { userId String Answer RoomSurveyAnswer @relation(fields: [answerId], references: [id]) answerId Int -} \ No newline at end of file +} diff --git a/src/modules/class/class.service.ts b/src/modules/class/class.service.ts index 0a3da73..2b9e84b 100644 --- a/src/modules/class/class.service.ts +++ b/src/modules/class/class.service.ts @@ -4,7 +4,9 @@ import { UpdateClassDto } from "./dto/update-class.dto"; import { PrismaService } from "nestjs-prisma"; import { Prisma } from "@prisma/client"; import { CreateRoomClassDto } from "./dto/create-room.dto"; -import * as moment from "moment"; +import * as moment from "moment-timezone"; + +moment.tz.setDefault("UTC"); @Injectable() export class ClassService { diff --git a/src/modules/class/dto/create-room.dto.ts b/src/modules/class/dto/create-room.dto.ts index fd752e4..8e34398 100644 --- a/src/modules/class/dto/create-room.dto.ts +++ b/src/modules/class/dto/create-room.dto.ts @@ -1,12 +1,12 @@ import { ApiProperty } from "@nestjs/swagger"; -import { IsArray, IsString, Matches } from "class-validator"; +import { IsArray, IsDateString, IsString, Matches } from "class-validator"; export class CreateRoomClassDto { @IsString() @ApiProperty() name: string; - @IsString() + @IsDateString() @ApiProperty() date: string; diff --git a/yarn.lock b/yarn.lock index 3795fb0..2eab65e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -414,46 +414,46 @@ resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== -"@prisma/client@^6.1.0": - version "6.1.0" - resolved "https://registry.yarnpkg.com/@prisma/client/-/client-6.1.0.tgz#179d3b70586e7be522f6f1f0a82cca01396f719a" - integrity sha512-AbQYc5+EJKm1Ydfq3KxwcGiy7wIbm4/QbjCKWWoNROtvy7d6a3gmAGkKjK0iUCzh+rHV8xDhD5Cge8ke/kiy5Q== +"@prisma/client@^6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@prisma/client/-/client-6.2.1.tgz#3d7d0c8669bba490247e1ffff67b93a516bd789f" + integrity sha512-msKY2iRLISN8t5X0Tj7hU0UWet1u0KuxSPHWuf3IRkB4J95mCvGpyQBfQ6ufcmvKNOMQSq90O2iUmJEN2e5fiA== -"@prisma/debug@6.1.0": - version "6.1.0" - resolved "https://registry.yarnpkg.com/@prisma/debug/-/debug-6.1.0.tgz#a27a1d144f72a3bc95061ecb0255e7554d9d59ec" - integrity sha512-0himsvcM4DGBTtvXkd2Tggv6sl2JyUYLzEGXXleFY+7Kp6rZeSS3hiTW9mwtUlXrwYbJP6pwlVNB7jYElrjWUg== +"@prisma/debug@6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@prisma/debug/-/debug-6.2.1.tgz#887719967c4942d125262e48f6c47c45d17c1f61" + integrity sha512-0KItvt39CmQxWkEw6oW+RQMD6RZ43SJWgEUnzxN8VC9ixMysa7MzZCZf22LCK5DSooiLNf8vM3LHZm/I/Ni7bQ== -"@prisma/engines-version@6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959": - version "6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959" - resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959.tgz#0b21ebf57362ffe35d0760c39855f90bbfa0f2fd" - integrity sha512-PdJqmYM2Fd8K0weOOtQThWylwjsDlTig+8Pcg47/jszMuLL9iLIaygC3cjWJLda69siRW4STlCTMSgOjZzvKPQ== +"@prisma/engines-version@6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69": + version "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69" + resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69.tgz#b84ce3fab44bfa13a22669da02752330b61745b2" + integrity sha512-7tw1qs/9GWSX6qbZs4He09TOTg1ff3gYsB3ubaVNN0Pp1zLm9NC5C5MZShtkz7TyQjx7blhpknB7HwEhlG+PrQ== -"@prisma/engines@6.1.0": - version "6.1.0" - resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-6.1.0.tgz#2195244a8ce33839a8131e4465624e21d1f8d042" - integrity sha512-GnYJbCiep3Vyr1P/415ReYrgJUjP79fBNc1wCo7NP6Eia0CzL2Ot9vK7Infczv3oK7JLrCcawOSAxFxNFsAERQ== +"@prisma/engines@6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-6.2.1.tgz#14ef56bb780f02871a728667161d997a14aedb69" + integrity sha512-lTBNLJBCxVT9iP5I7Mn6GlwqAxTpS5qMERrhebkUhtXpGVkBNd/jHnNJBZQW4kGDCKaQg/r2vlJYkzOHnAb7ZQ== dependencies: - "@prisma/debug" "6.1.0" - "@prisma/engines-version" "6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959" - "@prisma/fetch-engine" "6.1.0" - "@prisma/get-platform" "6.1.0" + "@prisma/debug" "6.2.1" + "@prisma/engines-version" "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69" + "@prisma/fetch-engine" "6.2.1" + "@prisma/get-platform" "6.2.1" -"@prisma/fetch-engine@6.1.0": - version "6.1.0" - resolved "https://registry.yarnpkg.com/@prisma/fetch-engine/-/fetch-engine-6.1.0.tgz#2a5174787bf57c9b1d5d400bb923e0dc6a73a794" - integrity sha512-asdFi7TvPlEZ8CzSZ/+Du5wZ27q6OJbRSXh+S8ISZguu+S9KtS/gP7NeXceZyb1Jv1SM1S5YfiCv+STDsG6rrg== +"@prisma/fetch-engine@6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@prisma/fetch-engine/-/fetch-engine-6.2.1.tgz#cd7eb7428a407105e0f3761dba536aefd41fc7f7" + integrity sha512-OO7O9d6Mrx2F9i+Gu1LW+DGXXyUFkP7OE5aj9iBfA/2jjDXEJjqa9X0ZmM9NZNo8Uo7ql6zKm6yjDcbAcRrw1A== dependencies: - "@prisma/debug" "6.1.0" - "@prisma/engines-version" "6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959" - "@prisma/get-platform" "6.1.0" + "@prisma/debug" "6.2.1" + "@prisma/engines-version" "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69" + "@prisma/get-platform" "6.2.1" -"@prisma/get-platform@6.1.0": - version "6.1.0" - resolved "https://registry.yarnpkg.com/@prisma/get-platform/-/get-platform-6.1.0.tgz#d4394a24ef91af6675a92382ed40e6e6e07eeb13" - integrity sha512-ia8bNjboBoHkmKGGaWtqtlgQOhCi7+f85aOkPJKgNwWvYrT6l78KgojLekE8zMhVk0R9lWcifV0Pf8l3/15V0Q== +"@prisma/get-platform@6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@prisma/get-platform/-/get-platform-6.2.1.tgz#34313cd0ee3587798ad33a7b57b6342dc8e66426" + integrity sha512-zp53yvroPl5m5/gXYLz7tGCNG33bhG+JYCm74ohxOq1pPnrL47VQYFfF3RbTZ7TzGWCrR3EtoiYMywUBw7UK6Q== dependencies: - "@prisma/debug" "6.1.0" + "@prisma/debug" "6.2.1" "@scarf/scarf@=1.4.0": version "1.4.0" @@ -2563,7 +2563,14 @@ mkdirp@^0.5.4: dependencies: minimist "^1.2.6" -moment@^2.30.1: +moment-timezone@^0.5.46: + version "0.5.46" + resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.46.tgz#a21aa6392b3c6b3ed916cd5e95858a28d893704a" + integrity sha512-ZXm9b36esbe7OmdABqIWJuBBiLLwAjrN7CE+7sYdCCx82Nabt1wHDj8TVseS59QIlfFPbOoiBPm6ca9BioG4hw== + dependencies: + moment "^2.29.4" + +moment@^2.29.4, moment@^2.30.1: version "2.30.1" resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how== @@ -2826,12 +2833,12 @@ prettier@^3.0.0: resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.4.2.tgz#a5ce1fb522a588bf2b78ca44c6e6fe5aa5a2b13f" integrity sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ== -prisma@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/prisma/-/prisma-6.1.0.tgz#738f657fdd5ab8e6775f385db81bf7e61c70fbaf" - integrity sha512-aFI3Yi+ApUxkwCJJwyQSwpyzUX7YX3ihzuHNHOyv4GJg3X5tQsmRaJEnZ+ZyfHpMtnyahhmXVfbTZ+lS8ZtfKw== +prisma@^6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/prisma/-/prisma-6.2.1.tgz#457b210326d66d0e6f583cc6f9cd2819b984408f" + integrity sha512-hhyM0H13pQleQ+br4CkzGizS5I0oInoeTw3JfLw1BRZduBSQxPILlJLwi+46wZzj9Je7ndyQEMGw/n5cN2fknA== dependencies: - "@prisma/engines" "6.1.0" + "@prisma/engines" "6.2.1" optionalDependencies: fsevents "2.3.3"