mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-29 01:19:41 +05:00
feat: add image crop modal
This commit is contained in:
parent
530fc1aad0
commit
5cde53c1d3
5 changed files with 202 additions and 21 deletions
|
@ -116,8 +116,22 @@ const months = [
|
|||
|
||||
export function unixToDate(unix: number, type: string = "short") {
|
||||
const date = new Date(unix * 1000);
|
||||
if (type === "short") return date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear();
|
||||
if (type === "full") return date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear() + ", " + date.getHours() + ":" + date.getMinutes();
|
||||
if (type === "short")
|
||||
return (
|
||||
date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear()
|
||||
);
|
||||
if (type === "full")
|
||||
return (
|
||||
date.getDate() +
|
||||
" " +
|
||||
months[date.getMonth()] +
|
||||
" " +
|
||||
date.getFullYear() +
|
||||
", " +
|
||||
date.getHours() +
|
||||
":" +
|
||||
date.getMinutes()
|
||||
);
|
||||
}
|
||||
|
||||
export const getSeasonFromUnix = (unix: number) => {
|
||||
|
@ -148,7 +162,9 @@ export function sinceUnixDate(unixInSeconds: number) {
|
|||
if (dateDifferenceSeconds < 86400) return `${hours} ${hoursName} назад`;
|
||||
if (dateDifferenceSeconds < 2592000) return `${days} ${daysName} назад`;
|
||||
|
||||
return date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear();
|
||||
return (
|
||||
date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear()
|
||||
);
|
||||
}
|
||||
|
||||
export function minutesToTime(min: number) {
|
||||
|
@ -248,3 +264,31 @@ export const SortList = {
|
|||
alphabet_descending: 5,
|
||||
alphabet_ascending: 6,
|
||||
};
|
||||
|
||||
export function b64toBlob(
|
||||
b64Data: string,
|
||||
contentType: string,
|
||||
sliceSize?: number
|
||||
) {
|
||||
contentType = contentType || "";
|
||||
sliceSize = sliceSize || 512;
|
||||
|
||||
var byteCharacters = atob(b64Data);
|
||||
var byteArrays = [];
|
||||
|
||||
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
||||
var slice = byteCharacters.slice(offset, offset + sliceSize);
|
||||
|
||||
var byteNumbers = new Array(slice.length);
|
||||
for (var i = 0; i < slice.length; i++) {
|
||||
byteNumbers[i] = slice.charCodeAt(i);
|
||||
}
|
||||
|
||||
var byteArray = new Uint8Array(byteNumbers);
|
||||
|
||||
byteArrays.push(byteArray);
|
||||
}
|
||||
|
||||
var blob = new Blob(byteArrays, { type: contentType });
|
||||
return blob;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue