Package-level declarations

Calendar-event SPI. NepaliCalendarEvent is one thing on one day, a public holiday, a festival, a programme or a meeting, and closesOffices says whether the institution is actually shut for it. NepaliEventProvider supplies them, NepaliCalendarPolicy pairs that list with the weekdays an institution never opens and answers statusOf / eventsOn / eventsIn / monthStatus, and the working-day helpers count by the same rule. spanningDays and spanningThrough expand something that runs longer than a day into the per-day entries the rest of the package reads. No event dataset ships with the library by design.

Types

Link copied to clipboard
data class NepaliCalendarEvent(val date: SimpleDate, val name: String, val kind: NepaliEventKind, val closesOffices: Boolean = kind.closesOfficesByDefault, val id: String? = null, val payload: String? = null)

Something that happens on one Bikram Sambat day: a public holiday, a festival, a school programme, a deadline, a birthday.

Link copied to clipboard
class NepaliCalendarPolicy(val weeklyOffDays: Set<Int> = NepaliWeekend.Default, val provider: NepaliEventProvider = NoOpEventProvider)

When one institution is closed, and what its calendar has on it: the days of the week it never opens, plus the events it keeps.

Link copied to clipboard
data class NepaliDayStatus(val isWeeklyOff: Boolean, val events: List<NepaliCalendarEvent>)

What one day is, as far as a NepaliCalendarPolicy is concerned: whether the week makes it a day off, and what is named on it.

Link copied to clipboard

What kind of thing an event is, which is what a calendar colors by.

Link copied to clipboard

Service-provider interface for supplying a calendar's events: public holidays, festivals, programmes, anything an app wants named on a day.

Link copied to clipboard

Day-of-week conventions.

Link copied to clipboard

No-op provider. Use as a default when an app wants the event-aware APIs but has not wired a data source yet. Behaves as if nothing is ever named and nothing ever closes.

Functions

Link copied to clipboard

The date days working days from from for the institution policy describes, with the Excel WORKDAY semantics of the provider overload.

fun NepaliDateConverter.addWorkingDays(from: SimpleDate, days: Int, provider: NepaliEventProvider, weekend: Set<Int> = NepaliWeekend.Default): SimpleDate

Returns the date that is days working days from from, skipping weekend and the closures provider reports. Follows Excel WORKDAY semantics:

Link copied to clipboard

Returns a NepaliSelectableDates that delegates to this one but additionally rejects any date provider says the institution is shut for.

Link copied to clipboard
fun NepaliSelectableDates.excludingWeekends(weekend: Set<Int> = NepaliWeekend.Default): NepaliSelectableDates

Returns a NepaliSelectableDates that delegates to this one but additionally rejects weekend days as defined by weekend (default: Saturday only).

Link copied to clipboard

A view of this provider carrying only the entries predicate accepts, for narrowing a shared list to what one screen cares about: filtered { it.kind == NepaliEventKind.GovernmentPublic }.

Link copied to clipboard

First working day at or after from for the institution policy describes. Returns from itself when that is already a working day.

fun NepaliDateConverter.nextWorkingDay(from: SimpleDate, provider: NepaliEventProvider, weekend: Set<Int> = NepaliWeekend.Default): SimpleDate

First working day at or after from, skipping both weekend days and the dates provider says the institution is shut for.

Link copied to clipboard

A provider reporting everything either side reports, which is how a national list and an institution's own list are put together.

Link copied to clipboard

This event on each of days consecutive days, starting on its own date, for a festival or a leave that runs longer than one day.

Link copied to clipboard

This event on each day from its own date through end, both ends included, which is the shape published holiday lists and leave requests usually state a span in.

Link copied to clipboard

Number of working days in the half-open range [start, end) for the institution policy describes, skipping both its weekly off days and the events that close it.

fun NepaliDateConverter.workingDaysBetween(start: SimpleDate, end: SimpleDate, provider: NepaliEventProvider, weekend: Set<Int> = NepaliWeekend.Default): Int

Number of working days in the half-open range [start, end), skipping both weekend days and the dates provider says the institution is shut for.