All files thaiDay.ts

92.85% Statements 13/14
88.88% Branches 8/9
100% Functions 1/1
92.85% Lines 13/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37      1x 1x 1x 8x     8x   1x     1x     1x     1x     1x     1x     1x   1x          
import dayjs from "dayjs";
import timezone from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
dayjs.extend(utc)
dayjs.extend(timezone)
const thaiTime = (date: Date) => {
  Iif (!date) {
    date = new Date()
  }
  switch(dayjs(date).tz('Asia/Bangkok').day()){
    case 1:
      return 'จันทร์'
 
    case 2:
      return 'อังคาร'
 
    case 3:
      return 'พุธ'
 
    case 4:
      return 'พฤหัสบดี'
 
    case 5:
      return 'ศุกร์'
 
    case 6:
      return 'เสาร์'
 
    case 0:
      return 'อาทิตย์'
  }
  return 'Invalid Date'
 
}
 
export default thaiTime