# GregorianCalendar

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/struct-gregoriancalendar/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct GregorianCalendar
```

The proleptic Gregorian calendar. It has no state.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L11)

## Members

- [`new`](#function-new)
- [`min_supported_date_time`](#function-min_supported_date_time)
- [`max_supported_date_time`](#function-max_supported_date_time)
- [`try_add_days`](#function-try_add_days)
- [`add_days`](#function-add_days)
- [`try_add_months`](#function-try_add_months)
- [`add_months`](#function-add_months)
- [`try_add_years`](#function-try_add_years)
- [`add_years`](#function-add_years)
- [`get_day_of_week`](#function-get_day_of_week)
- [`get_days_in_month`](#function-get_days_in_month)
- [`get_week_of_year`](#function-get_week_of_year)

<a id="function-new"></a>

### new

```rust
const fn new() -> GregorianCalendar
```

Creates the calendar.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L15)

<a id="function-min_supported_date_time"></a>

### min_supported_date_time

```rust
const fn min_supported_date_time(self: &Self) -> DateTime
```

The earliest date the calendar supports.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L20)

<a id="function-max_supported_date_time"></a>

### max_supported_date_time

```rust
const fn max_supported_date_time(self: &Self) -> DateTime
```

The latest date the calendar supports.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L25)

<a id="function-try_add_days"></a>

### try_add_days

```rust
fn try_add_days(self: &Self, time: DateTime, days: i32) -> Option<DateTime>
```

`time` moved by a number of days; `None` when the result is out of
range (.NET throws `ArgumentException`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L31)

<a id="function-add_days"></a>

### add_days

```rust
fn add_days(self: &Self, time: DateTime, days: i32) -> DateTime
```

`time` moved by a number of days. Panics when the result is out of range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L37)

<a id="function-try_add_months"></a>

### try_add_months

```rust
fn try_add_months(self: &Self, time: DateTime, months: i32) -> Option<DateTime>
```

`time` moved by a number of months, keeping the day where the
resulting month has it; `None` when `months` is not in
-120000..=120000 or the result is out of range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L44)

<a id="function-add_months"></a>

### add_months

```rust
fn add_months(self: &Self, time: DateTime, months: i32) -> DateTime
```

`time` moved by a number of months. Panics when out of range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L50)

<a id="function-try_add_years"></a>

### try_add_years

```rust
fn try_add_years(self: &Self, time: DateTime, years: i32) -> Option<DateTime>
```

`time` moved by a number of years; `None` when the result is out of range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L55)

<a id="function-add_years"></a>

### add_years

```rust
fn add_years(self: &Self, time: DateTime, years: i32) -> DateTime
```

`time` moved by a number of years. Panics when out of range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L61)

<a id="function-get_day_of_week"></a>

### get_day_of_week

```rust
fn get_day_of_week(self: &Self, time: DateTime) -> DayOfWeek
```

The day of the week of `time`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L66)

<a id="function-get_days_in_month"></a>

### get_days_in_month

```rust
fn get_days_in_month(self: &Self, year: i32, month: i32) -> i32
```

The number of days of a month. Panics for an invalid year or month.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L72)

<a id="function-get_week_of_year"></a>

### get_week_of_year

```rust
fn get_week_of_year(self: &Self, time: DateTime, rule: CalendarWeekRule, first_day_of_week: DayOfWeek) -> i32
```

The number of the week of the year that contains `time`, counted from
one, for the given rule and first day of the week.

As in .NET, the last days of December are never counted into the first
week of the following year: they get the number 53 (or 52) even where
ISO 8601 says 1. Use `IsoWeek::get_week_of_year` for ISO numbers.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/gregorian_calendar.rs#L82)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceKeyObject`](/docs/0.5.0/api/ferroui-base/controls/trait-resourcekeyobject/)
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Copy`
- `Debug`
- `Default`
- `StructuralPartialEq`
- `PartialEq`
- `Eq`
- `Hash`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
