diff --git a/backend/feature/post/src/adapter/delivery/create_post_request_dto.rs b/backend/feature/post/src/adapter/delivery/create_post_request_dto.rs index 9c273d2..053b6a6 100644 --- a/backend/feature/post/src/adapter/delivery/create_post_request_dto.rs +++ b/backend/feature/post/src/adapter/delivery/create_post_request_dto.rs @@ -12,8 +12,8 @@ pub struct CreatePostRequestDto { pub content: String, pub label_ids: Vec, - #[schema(required)] - pub published_time: Option, + #[schema(required, format = DateTime)] + pub published_time: Option, } impl CreatePostRequestDto { @@ -28,8 +28,8 @@ impl CreatePostRequestDto { labels: Vec::new(), published_time: self .published_time - .map(|micros| DateTime::::from_timestamp_micros(micros)) - .flatten(), + .and_then(|time_str| DateTime::parse_from_rfc3339(&time_str).ok()) + .map(|dt| dt.with_timezone(&Utc)), }, content: self.content, } diff --git a/backend/feature/post/src/adapter/delivery/post_info_response_dto.rs b/backend/feature/post/src/adapter/delivery/post_info_response_dto.rs index dd33091..176b9c3 100644 --- a/backend/feature/post/src/adapter/delivery/post_info_response_dto.rs +++ b/backend/feature/post/src/adapter/delivery/post_info_response_dto.rs @@ -12,7 +12,9 @@ pub struct PostInfoResponseDto { pub description: String, pub preview_image_url: String, pub labels: Vec, - pub published_time: Option, + + #[schema(format = DateTime)] + pub published_time: Option, } impl From for PostInfoResponseDto { @@ -27,9 +29,7 @@ impl From for PostInfoResponseDto { .into_iter() .map(LabelResponseDto::from) .collect(), - published_time: entity - .published_time - .map(|datetime| datetime.timestamp_micros()), + published_time: entity.published_time.map(|datetime| datetime.to_rfc3339()), } } } diff --git a/backend/feature/post/src/adapter/delivery/update_post_request_dto.rs b/backend/feature/post/src/adapter/delivery/update_post_request_dto.rs index f7f3683..7ae2128 100644 --- a/backend/feature/post/src/adapter/delivery/update_post_request_dto.rs +++ b/backend/feature/post/src/adapter/delivery/update_post_request_dto.rs @@ -12,8 +12,8 @@ pub struct UpdatePostRequestDto { pub content: String, pub label_ids: Vec, - #[schema(required)] - pub published_time: Option, + #[schema(required, format = DateTime)] + pub published_time: Option, } impl UpdatePostRequestDto { @@ -28,8 +28,8 @@ impl UpdatePostRequestDto { labels: Vec::new(), published_time: self .published_time - .map(|micros| DateTime::::from_timestamp_micros(micros)) - .flatten(), + .and_then(|time_str| DateTime::parse_from_rfc3339(&time_str).ok()) + .map(|dt| dt.with_timezone(&Utc)), }, content: self.content, } diff --git a/frontend/src/lib/post/adapter/gateway/postInfoResponseDto.ts b/frontend/src/lib/post/adapter/gateway/postInfoResponseDto.ts index 1ada6b5..e6393b2 100644 --- a/frontend/src/lib/post/adapter/gateway/postInfoResponseDto.ts +++ b/frontend/src/lib/post/adapter/gateway/postInfoResponseDto.ts @@ -8,7 +8,7 @@ export const PostInfoResponseSchema = z.object({ description: z.string(), preview_image_url: z.url(), labels: z.array(LabelResponseSchema), - published_time: z.number().int() + published_time: z.iso.datetime() }); export class PostInfoResponseDto { @@ -43,7 +43,7 @@ export class PostInfoResponseDto { description: parsedJson.description, previewImageUrl: new URL(parsedJson.preview_image_url), labels: parsedJson.labels.map((label) => LabelResponseDto.fromJson(label)), - publishedTime: new Date(parsedJson.published_time / 1000) + publishedTime: new Date(parsedJson.published_time) }); }