diff --git a/components/torrent/TorrentCreatedByTab.vue b/components/torrent/TorrentCreatedByTab.vue new file mode 100644 index 00000000..d493e650 --- /dev/null +++ b/components/torrent/TorrentCreatedByTab.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/components/torrent/TorrentCreationDateTab.vue b/components/torrent/TorrentCreationDateTab.vue new file mode 100644 index 00000000..33c084d9 --- /dev/null +++ b/components/torrent/TorrentCreationDateTab.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/components/torrent/TorrentDetails.vue b/components/torrent/TorrentDetails.vue index bfd8ca1b..358a2fd6 100644 --- a/components/torrent/TorrentDetails.vue +++ b/components/torrent/TorrentDetails.vue @@ -17,6 +17,9 @@
+ + +
diff --git a/components/torrent/TorrentEncodingTab.vue b/components/torrent/TorrentEncodingTab.vue new file mode 100644 index 00000000..3c9a0275 --- /dev/null +++ b/components/torrent/TorrentEncodingTab.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/src/helpers/DateConverter.ts b/src/helpers/DateConverter.ts new file mode 100644 index 00000000..efa044fe --- /dev/null +++ b/src/helpers/DateConverter.ts @@ -0,0 +1,21 @@ +type UnixTimestamp = number; +type FormattedDate = string; + +class InvalidDateError extends Error {} + +/** + * Takes the date in seconds from Unix Epoch time and converts it to human readable format. + * + * For example: 1701688451 -> "Mon Dec 04 2023" + */ + +export function formatTimestamp (creationDate: UnixTimestamp): FormattedDate | Error { + const milliseconds = creationDate * 1000; + + const convertedDate = new Date(milliseconds); + + return isNaN(convertedDate.valueOf()) + ? new InvalidDateError( + `Invalid date. Could not create a new date from timestamp value: ${creationDate}`) + : convertedDate.toDateString(); +}