Skip to content

Commit

Permalink
fix(backoffice): mm local time
Browse files Browse the repository at this point in the history
  • Loading branch information
alonp99 committed Oct 26, 2024
1 parent 5448ecd commit 7447e28
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
3 changes: 2 additions & 1 deletion apps/backoffice-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"lint": "eslint . --fix",
"start": "vite",
"dev": "vite",
"build": "vite build",
"build": "cross-env NODE_OPTIONS=--max-old-space-size=32768 vite build",
"test": "vitest run --passWithNoTests",
"test:unit": "vitest run --passWithNoTests",
"test:e2e": "playwright test",
Expand Down Expand Up @@ -156,6 +156,7 @@
"@typescript-eslint/parser": "^5.30.0",
"@vitejs/plugin-react-swc": "^3.0.1",
"autoprefixer": "^10.4.7",
"cross-env": "^7.0.3",
"cspell": "^6.31.2",
"eslint": "8.22.0",
"eslint-config-prettier": "^8.5.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import dayjs from 'dayjs';
import React from 'react';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';

// Add these plugins to dayjs
dayjs.extend(utc);
dayjs.extend(timezone);

import { createColumnHelper } from '@tanstack/react-table';
import { BusinessReportStatus, TBusinessReport } from '@/domains/business-reports/fetchers';
import { titleCase } from 'string-ts';
Expand Down Expand Up @@ -55,8 +61,11 @@ export const columns = [
return <TextWithNAFallback>{createdAt}</TextWithNAFallback>;
}

const date = dayjs(createdAt).format('MMM DD, YYYY');
const time = dayjs(createdAt).format('hh:mm');
// Convert UTC time to local browser time
const localDateTime = dayjs.utc(createdAt).local();

const date = localDateTime.format('MMM DD, YYYY');
const time = localDateTime.format('HH:mm');

return (
<div className={`flex flex-col space-y-0.5`}>
Expand Down
8 changes: 5 additions & 3 deletions pnpm-lock.yaml

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

0 comments on commit 7447e28

Please sign in to comment.