feat: add date time format function
This commit is contained in:
parent
71401da000
commit
48661a9259
1 changed files with 18 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import { notFoundError } from "../utils/error";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import { getFileBuffer, listFile } from "../utils/minio";
|
import { getFileBuffer, listFile } from "../utils/minio";
|
||||||
|
import { dateFormat } from "../utils/datetime";
|
||||||
|
|
||||||
const quotationData = (id: string) =>
|
const quotationData = (id: string) =>
|
||||||
prisma.quotation.findFirst({
|
prisma.quotation.findFirst({
|
||||||
|
|
@ -128,6 +129,23 @@ export class DocTemplateController extends Controller {
|
||||||
template,
|
template,
|
||||||
data: record,
|
data: record,
|
||||||
additionalJsContext: {
|
additionalJsContext: {
|
||||||
|
date: (date: string, locale?: string) => dateFormat({ date, locale }),
|
||||||
|
dateTime: (date: string, locale?: string) => dateFormat({ date, withTime: true, locale }),
|
||||||
|
dateLong: (date: string, locale?: string) =>
|
||||||
|
dateFormat({ date, locale, monthStyle: "long" }),
|
||||||
|
dateLongTime: (date: string, locale?: string) =>
|
||||||
|
dateFormat({ date, withTime: true, locale, monthStyle: "long" }),
|
||||||
|
dateTH: (date: string) => dateFormat({ date, locale: "th-TH" }),
|
||||||
|
dateTimeTH: (date: string) => dateFormat({ date, withTime: true, locale: "th-TH" }),
|
||||||
|
dateLongTH: (date: string) => dateFormat({ date, locale: "th-TH", monthStyle: "long" }),
|
||||||
|
dateTimeLongTH: (date: string) =>
|
||||||
|
dateFormat({ date, withTime: true, locale: "th-TH", monthStyle: "long" }),
|
||||||
|
dateEN: (date: string) => dateFormat({ date, locale: "en-US" }),
|
||||||
|
dateTimeEN: (date: string) =>
|
||||||
|
dateFormat({ date, withTime: true, locale: "en-US", monthStyle: "long" }),
|
||||||
|
dateLongEN: (date: string) => dateFormat({ date, locale: "en-US" }),
|
||||||
|
dateTimeLongEN: (date: string) =>
|
||||||
|
dateFormat({ date, withTime: true, locale: "en-US", monthStyle: "long" }),
|
||||||
addressFull,
|
addressFull,
|
||||||
addressFullTH: (addr: FullAddress) => addressFull(addr, "th"),
|
addressFullTH: (addr: FullAddress) => addressFull(addr, "th"),
|
||||||
addressFullEN: (addr: FullAddress) => addressFull(addr, "en"),
|
addressFullEN: (addr: FullAddress) => addressFull(addr, "en"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue