Files
evilspins/server/utils/getCardFromDate.ts
valere 7fa6f6ccc8
All checks were successful
Deploy App / build (push) Successful in 2m15s
Deploy App / deploy (push) Successful in 27s
sql server + platine v2
2026-02-06 22:52:02 +01:00

22 lines
578 B
TypeScript

import type { Suit, Rank } from '../../types/types'
export function getCardFromDate(date: Date): { suit: Suit; rank: Rank } {
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const suit: Suit =
month >= 12 || month <= 2
? '♠'
: month >= 3 && month <= 5
? '♥'
: month >= 6 && month <= 8
? '♦'
: '♣'
const ranks: Rank[] = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'V', 'D', 'R']
const rank = ranks[(day + hour) % ranks.length]
return { suit, rank }
}