Skip to content

Pickers ​

Registry items: bs-date-picker, bs-time-picker, bs-datetime-picker.

Date callbacks return BsDate only — see BS ↔ AD on the overview page.

Display formatting ​

All three pickers format the trigger label with date-fns-style tokens mapped to Bikram Sambat data (weekday/month names from Hamro Patro). No date-fns dependency.

Precedence: formatValue → formatPattern → built-in default.

PickerDefault patternExample (en)
BsDatePickerEEEE, d MMMM yyyyFriday, 26 Ashad 2083
(compact)EEE, d MMM yyyyFri, 26 Ash 2083
BsTimePickerh:mm a10:51 PM
BsDateTimePickerEEEE, d MMMM yyyy, h:mm aFriday, 26 Ashad 2083, 10:51 PM

Props (all pickers) ​

PropTypeDescription
formatPatternstringdate-fns-style BS tokens (see table below)
formatValue(value, locale, …) => stringFull override; takes precedence over formatPattern

Use single quotes for literals, e.g. 'at' h:mm a → at 10:51 PM.

Date tokens ​

TokenOutput
EEEEFull weekday (Friday / शुक्रबार)
EEEShort weekday
MMMMFull BS month (Ashad / असार)
MMMShort BS month
yyyy4-digit BS year
yy2-digit BS year
MM / MMonth number (padded / unpadded)
dd / dDay of month (padded / unpadded)

Nepali locale uses Nepali digits where applicable.

Time tokens ​

TokenOutput
HH / H24-hour hour (padded / unpadded)
hh / h12-hour hour when is24Hour={false}; maps to 24h when is24Hour={true}
mm / mMinute (padded / unpadded)
aAM/PM (AM/PM or एम/पिम); omitted in 24-hour mode

Helpers ​

ts
import {
  formatBsDatePattern,
  BS_DATE_COMPACT_DISPLAY_PATTERN,
  BS_DATE_DISPLAY_PATTERN,
} from "@/lib/bs-day-picker/pattern"
import {
  formatBsTimePattern,
  formatBsDateTimePattern,
  BS_TIME_DISPLAY_PATTERN,
  BS_DATETIME_DISPLAY_PATTERN,
} from "@/lib/bs-time-picker/time/pattern"

For Gregorian labels, use formatValue with toAdDate() and your own formatter (e.g. date-fns).

tsx
<BsDateTimePicker
  value={bsValue}
  onChange={setBsValue}
  locale="en"
  formatPattern="EEE d MMM yyyy, HH:mm"
  is24Hour
/>

BsDatePicker ​

PropTypeDefaultDescription
valueBsDate—Selected value
onChange(value?: BsDate) => void—Change handler (web)
onValueChange(value?: BsDate) => void—Change handler (native)
locale"en" | "ne""ne"Display locale
placeholderstring—Trigger placeholder
formatPatternstringEEEE, d MMMM yyyyTrigger label pattern
formatValue(value, locale) => string—Custom trigger label
disabledboolean—Disable trigger
PlatformUX
iOSBottom sheet with year / month / day wheels
AndroidMaterial calendar dialog
WebPopover with BsCalendar

BsTime ​

ts
type BsTime = {
  hour: number; // 0–23
  minute: number; // 0–59
};

Internal storage is always 24-hour. Set is24Hour={false} on pickers for 12-hour display with AM/PM.

Nepali period labels in the picker UI: एम (AM), पिम (PM).

BsTimePicker ​

PropTypeDefaultDescription
valueBsTime—Selected time
onChange(value?: BsTime) => void—Change handler (web)
onValueChange(value?: BsTime) => void—Change handler (native)
locale"en" | "ne""ne"Labels and digits
is24Hourbooleanfalse24h vs 12h + AM/PM
placeholderstring—Trigger placeholder
formatPatternstringh:mm aTrigger label pattern
formatValue(value, locale, is24Hour) => string—Custom trigger label
disabledboolean—Disable trigger
PlatformUX
iOSBottom sheet with hour / minute / AM·PM wheels
AndroidMaterial time dialog (digital + analog clock)
WebPopover with hour, minute, and period selects

BsDateTime ​

ts
type BsDateTime = BsDate & BsTime;
// { year, month, day, hour, minute }

BS ↔ AD datetime ​

Use toAdDate() when submitting to APIs that expect a Gregorian Date:

ts
import type { BsDateTime } from "@/lib/bs-time-picker/time/types";
import { toAdDate } from "@/lib/bs-datetime-picker";

function submitJourney(bsDateTime: BsDateTime) {
  const ad = toAdDate(bsDateTime); // Date in local timezone or null if day missing from data
  if (!ad) return;
  // e.g. OTP journeyDate
}
HelperReturns
toAdDate(bsDateTime)Date or null (uses getDayAdDate + time)
formatBsDateTime()Default pattern: Friday, 26 Ashad 2083, 10:51 PM
formatBsDateTimePattern()Custom pattern formatting
formatBsDateLongWithWeekday()Date only, e.g. Friday, 26 Ashad 2083
getDefaultBsDateTime()Today + now as BsDateTime
mergeBsDateTime(date, time)Combine BsDate + BsTime

BsDateTimePicker ​

Same props as BsTimePicker, plus date selection. Web uses onChange; native uses onValueChange.

PropTypeDefaultDescription
formatPatternstringEEEE, d MMMM yyyy, h:mm aTrigger label pattern
formatValue(value, locale, is24Hour) => string—Custom trigger label
PlatformUX
iOSBottom sheet: chronological date wheel + hour/minute wheels
AndroidMaterial calendar dialog → time dialog
WebPopover: calendar + time selects
  • BsDayPicker — headless calendar used inside date pickers
  • API overview — shared BsDate type and date BS ↔ AD helpers