Documentation
¶
Index ¶
- Constants
- type APIError
- type Client
- func (c *Client) GetBy(params Params) ([]DayType, error)
- func (c *Client) GetByPeriod(date1, date2 string, params Params) ([]DayType, error)
- func (c *Client) IsLeap(year int) (bool, error)
- func (c *Client) Today(params Params) (*DayType, error)
- func (c *Client) Tomorrow(params Params) (*DayType, error)
- type CountryCode
- type DayType
- type ErrorCode
- type Params
- type YearType
Examples ¶
Constants ¶
View Source
const ( // DayTypeWorking working day DayTypeWorking DayType = "0" // DayTypeNonWorking non working day DayTypeNonWorking DayType = "1" // DayTypeHalfHoliday half holiday DayTypeHalfHoliday DayType = "2" // DayTypeWorkingCovid working day for Covid DayTypeWorkingCovid DayType = "4" // YearTypeNotLeap leap year YearTypeNotLeap YearType = "0" // YearTypeLeap non leap year YearTypeLeap YearType = "1" // ErrorCodeWrongDate wrong date err ErrorCodeWrongDate ErrorCode = "100" // ErrorCodeNotFound not found err ErrorCodeNotFound ErrorCode = "101" // ErrorCodeInternalError internal error ErrorCodeInternalError ErrorCode = "199" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for requests to isdayoff.ru
func NewWithClient ¶
NewWithClient initiates client with custom http client
func (*Client) GetBy ¶
GetBy Get data by particular params
Example ¶
client := New()
month := time.January
days, err := client.GetBy(Params{
Year: 2024,
Month: &month,
})
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("January 2024 has %d days\n", len(days))
Output: January 2024 has 31 days
func (*Client) GetByPeriod ¶
GetByPeriod Get data for arbitrary period (date1 to date2) Maximum 366 days can be requested date1 and date2 should be in format YYYYMMDD
func (*Client) IsLeap ¶
IsLeap checks if year is leap
Example ¶
client := New()
isLeap, err := client.IsLeap(2020)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("2020 is leap year: %v\n", isLeap)
Output: 2020 is leap year: true
type CountryCode ¶
type CountryCode string
CountryCode type
const ( // CountryCodeBelarus BY - Белоруссия CountryCodeBelarus CountryCode = "by" // CountryCodeKazakhstan KZ - Казахстан CountryCodeKazakhstan CountryCode = "kz" // CountryCodeRussia RU - Россия (по умолчанию) CountryCodeRussia CountryCode = "ru" // CountryCodeUkraine UA - Украина CountryCodeUkraine CountryCode = "ua" // CountryCodeUSA USA - США (расширенный код) CountryCodeUSA CountryCode = "us" // CountryCodeUzbekistan UZ - Узбекистан (расширенный код) CountryCodeUzbekistan CountryCode = "uz" // CountryCodeTurkey TR - Турция (расширенный код) CountryCodeTurkey CountryCode = "tr" )
type Params ¶
type Params struct {
Year int
Month *time.Month
Day *int
CountryCode *CountryCode
Pre *bool // помечать сокращённые рабочие дни цифрой 2
Covid *bool // помечать рабочие дни цифрой 4 (в связи с пандемией COVID-19)
SixDayWeek *bool // считать, что неделя шестидневная (sd)
TZ *string
}
Params contains various filters for request
Click to show internal directories.
Click to hide internal directories.