Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add short section on type use-cases to README.md #8

Merged
merged 1 commit into from
Apr 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ The library provides the basic set of types for working with date and time:
- `CalendarPeriod` to represent a difference between two instants decomposed into calendar units. The latter are
listed in `CalendarUnit` enum.

### Type use-cases

Here is some basic advice on how to choose which of the date-carrying types to use in what cases:

- Use `Instant` to represent a timestamp of the event that had already happened in the past (like a timestamp of
a log entry) or will definitely happen in a well-defined instant of time in the future not far away from now
(like an order confirmation deadline in 1 hour from now).
- Use `LocalDateTime` to represent a time of the event that is scheduled to happen in the far future at a certain
local time (like a scheduled meeting in a few months from now). You'll have to keep track of the `TimeZone` of
the scheduled event separately. Try to avoid converting future events to `Instant` in advance, because time-zone
rules might change unexpectedly in the future.
Also, use `LocalDateTime` to decode an `Instant` to its local date-time components for display and UIs.
- Use `LocalDate` to represent a date of the event that does not have a specific time associated with it (like a birthday).

## Operations

With the above types you can get the following operations done.
Expand Down