Sootzani-Inspector/lib/utils.ts

36 lines
925 B
TypeScript

import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import jalaliday from "jalaliday";
import JSEncrypt from "jsencrypt";
dayjs.extend(jalaliday);
dayjs.extend(utc);
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function convertDate(date: string) {
const convertedDate = dayjs(date)
.calendar("jalali")
.locale("fa")
.format("YYYY/M/DD");
return convertedDate;
}
export function convertFullTime(date: string) {
const convertedDate = dayjs(date)
.calendar("jalali")
.locale("fa")
.format(" HH:mm - YYYY/M/DD");
return convertedDate;
}
export function Decrypt(encryptedData: any, privateKey: any) {
const decryptor = new JSEncrypt();
decryptor.setPrivateKey(privateKey);
const decrypted = decryptor.decrypt(encryptedData);
return decrypted;
}