Introduction | period-rust | Spatie       

 SPATIE  

  Period Rust 
==============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Period-rust](https://spatie.be/docs/period-rust/v1)  Introduction

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/period-rust/v1) 

  Introduction    
- [ Introduction ](https://spatie.be/docs/period-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/period-rust/v1/support-us)
- [ Installation ](https://spatie.be/docs/period-rust/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/period-rust/v1/usage)
- [ Testing ](https://spatie.be/docs/period-rust/v1/testing)
- [ Changelog ](https://spatie.be/docs/period-rust/v1/changelog)

 Period Rust 
=============

 [    Repository ](https://github.com/spatie/period-rust) 

 [    Open Issues ](https://github.com/spatie/period-rust/issues) 

    0 

    0 

Introduction
------------

This package adds support for comparing multiple dates with each other. You can calculate the overlaps and differences between n-amount of periods, as well as some more basic comparisons between two periods.

Periods can be constructed from date strings or [Jiff 1.x](https://docs.rs/jiff/1) dates, timestamps and timezone-aware dates. Implement `IntoDate` to accept another date type.

Jiff is re-exported as `spatie_period::jiff`. When upgrading from Jiff 0.2, replace `Zoned` with `ZonedDateTime` and `to_zoned` with `to_zoned_datetime`. Date types from Jiff 0.2 cannot be passed directly to this version of the package.

```
use spatie_period::{Period, jiff::{ZonedDateTime, civil::date, tz::TimeZone}};
let start: ZonedDateTime = date(2024, 2, 3).to_zoned_datetime(TimeZone::UTC)?;
let period = Period::make(&start, date(2024, 2, 5))?;

assert_eq!(period.start(), &start);
assert_eq!(period.length()?, 3);
```

Periods are always immutable, there's never the worry about your input dates being changed.

Continue with [installation](installation-and-setup) and [usage](usage).

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
