Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add date time based on user timezone #196

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion middleware/app/api/routes/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def post_upload_return_link_qr(
return {
"url": file_url,
"QR": qr_download_url,
"expiration_date": formatted_expires_at,
"expiration_date": expires_at.isoformat(),
"downloads_allowed": str(upload_metadata["max_download"]),
}

Expand Down
19 changes: 19 additions & 0 deletions ui/package-lock.json

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

1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"axios": "^1.6.7",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns-tz": "^3.1.3",
"file-saver": "^2.0.5",
"framer-motion": "^11.1.7",
"jszip": "^3.10.1",
Expand Down
5 changes: 4 additions & 1 deletion ui/src/app/(pages)/(protected)/history/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ function HistoryPage() {
const responseData = await historyResponse.json()

for (const fileName of responseData) {
const created = fileName['created_at']
let created = fileName['created_at']
const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone
created = created.toLocaleString('en-US', { timeZone: userTimezone })

const date = new Date(created)
const options = {
year: '2-digit',
Expand Down
11 changes: 9 additions & 2 deletions ui/src/app/(pages)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
UploadIcon,
} from '@radix-ui/react-icons'
import axios from 'axios'
import { formatInTimeZone } from 'date-fns-tz'
import { motion } from 'framer-motion'
import Image from 'next/image'
import { useRouter } from 'next/navigation'
Expand Down Expand Up @@ -385,9 +386,15 @@ export default function Home() {
const data = await postUploadResponse.json()
const shareURL = data.url
const shareQR = data.QR
const expirationDate = data.expiration_date
const downloadsAllowed = data.downloads_allowed

const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone
const expirationDate = formatInTimeZone(
data.expiration_date,
userTimezone,
'yyyy-MM-dd HH:mm:ss zzz',
)

return { shareURL, shareQR, expirationDate, downloadsAllowed }
}

Expand Down Expand Up @@ -477,7 +484,7 @@ export default function Home() {
duration: 0.5,
ease: [0.4, 0.0, 0.2, 1],
}}
className=" px-4 text-sm lg:text-lg font-bold text-white dark:text-white max-w-xl leading-relaxed lg:leading-snug text-center mx-auto "
className="px-4 text-xs lg:text-lg font-bold text-white dark:text-white max-w-xl leading-relaxed lg:leading-snug text-center mx-auto "
>
Experience seamless file sharing with ByteShare.
<br />
Expand Down
Loading