thai-datetime
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Thai Datetime

Provide datetime string in Thai.

Demo is available here.

Install

npm install thai-datetime

or

yarn add thai-datetime

Example

import {
  getThaiDay,
  getThaiFullDay,
  getThaiMonth,
  getThaiFullMonth,
  getThaiYear,
  getThaiFullTime,
  getThaiShortTime,
} from "thai-datetime";

// set as local time 1991-12-02 10:30am
const date = new Date();
date.setFullYear(1991);
date.setMonth(11);
date.setDate(2);
date.setHours(10);
date.setMinutes(30);

getThaiDay(date); // "จ."
getThaiFullDay(date); // "วันจันทร์"
getThaiMonth(date); // "ธ.ค."
getThaiFullMonth(date); // "ธันวาคม"
getThaiYear(date, { inWesternDigit: true }) // "2534"
getThaiFullTime(date, { inWesternDigit: true }) // "10 นาฬิกา 30 นาที"
getThaiShortTime(date, { inWesternDigit: true }) // "10 โมง 30 ตอนเช้า"
getThaiYear(date); // "๒๕๓๔"
getThaiFullTime(date); // "๑๐ นาฬิกา ๓๐ นาที"
getThaiShortTime(date); // "๑๐ โมง ๓๐ ตอนเช้า"
getFullThaiDateString(date); // "วันจันทร์ที่ ๒ ธันวาคมพศ ๒๕๓๔"

Usage

getThaiDay

getThaiDay = (date: Date): string

getThaiFullDay

getThaiFullDay = (date: Date): string

getThaiMonth

getThaiMonth = (date: Date): string

getThaiFullMonth

getThaiFullMonth = (date: Date): string

getThaiYear

getThaiYear = (date: Date): number

getThaiFullTime

getThaiFullTime = (date: Date): string

getThaiShortTime

getThaiShortTime = (date: Date): string

getThaiDay

// @return: possible Cantonese romanisation for each Chinese character in the input string
getRoman( input: string ): Array<string[]>

Contribute

Project owner chunlaw is learning Thai, and everyone is welcome to contribute.

License

MIT license

Package Sidebar

Install

npm i thai-datetime

Weekly Downloads

10

Version

1.0.4

License

MIT

Unpacked Size

34.6 kB

Total Files

13

Last publish

Collaborators

  • chunlaw