-
Notifications
You must be signed in to change notification settings - Fork 103
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
docs: fix typos in README.md #328
Open
EchoEllet
wants to merge
2
commits into
Kotlin:master
Choose a base branch
from
EchoEllet:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,26 +11,26 @@ | |
|
||
A multiplatform Kotlin library for working with date and time. | ||
|
||
See [Using in your projects](#using-in-your-projects) for the instructions how to setup a dependency in your project. | ||
See [Using in your projects](#using-in-your-projects) for the instructions on how to set up a dependency in your project. | ||
|
||
## Design overview | ||
|
||
There are a few guiding principles in the design of `kotlinx-datetime`. First of all, it is pragmatic, focused | ||
There are a few guiding principles in the design of `kotlinx-datetime`. First of all, it is pragmatic and focused | ||
on the most common problems developers face every day (pun intended) when working with dates and times. It is not | ||
all-encompassing and lacks some domain-specific utilities that special-purpose applications might need. | ||
We chose convenience over generality, so the API surface this library provides is as minimal as possible | ||
to meet the use-cases. | ||
to meet the use cases. | ||
|
||
The library puts a clear boundary between the physical time of an instant and the local, time-zone dependent | ||
The library puts a clear boundary between the physical time of an instant and the local, time-zone-dependent | ||
civil time, consisting of components such as year, month, etc that people use when talking about time. | ||
We intentionally avoid entities in the library that mix both together and could be misused. | ||
However, there are convenience operations that take, for example, a physical instant and perform a calendar-based | ||
adjustment (such as adding a month); all such operations | ||
explicitly take a time-zone information as parameter to clearly state that their result depends on the civil time-zone | ||
explicitly take time-zone information as a parameter to clearly state that their result depends on the civil time zone | ||
rules which are subject to change at any time. | ||
|
||
The library is based on the ISO 8601 international standard, other ways to represent dates and times are out of | ||
its scope. Internationalization (such as locale-specific month and day names) is out the scope, too. | ||
its scope. Internationalization (such as locale-specific month and day names) is out of the scope, too. | ||
|
||
## Types | ||
|
||
|
@@ -59,7 +59,7 @@ Here is some basic advice on how to choose which of the date-carrying types to u | |
|
||
- 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 | ||
the scheduled event separately. Try to avoid converting future events to `Instant` in advance, because time zone | ||
rules might change unexpectedly in the future. In this [blog post](https://codeblog.jonskeet.uk/2019/03/27/storing-utc-is-not-a-silver-bullet/), you can read more about why it's not always | ||
a good idea to use `Instant` everywhere. | ||
|
||
|
@@ -71,7 +71,7 @@ Here is some basic advice on how to choose which of the date-carrying types to u | |
|
||
## Operations | ||
|
||
With the above types you can get the following operations done. | ||
With the above types, you can get the following operations done. | ||
|
||
|
||
### Getting the current moment of time | ||
|
@@ -95,7 +95,7 @@ val currentMoment = Clock.System.now() | |
|
||
### Converting an instant to local date and time components | ||
|
||
An `Instant` is just a counter of high resolution time intervals since the beginning of time scale. | ||
An `Instant` is just a counter of high-resolution time intervals since the beginning of the time scale. | ||
To get human readable components from an `Instant` value, you need to convert it to the `LocalDateTime` | ||
type that represents date and time components without a reference to the particular time zone. | ||
|
||
|
@@ -152,31 +152,31 @@ val knownDate = LocalDate(2020, 2, 21) | |
|
||
### Getting local time components | ||
|
||
A `LocalTime` represents local time without date. You can obtain one from an `Instant` | ||
A `LocalTime` represents local time without a date. You can obtain one from an `Instant` | ||
by converting it to `LocalDateTime` and taking its `time` property. | ||
|
||
```kotlin | ||
val now: Instant = Clock.System.now() | ||
val thisTime: LocalTime = now.toLocalDateTime(TimeZone.currentSystemDefault()).time | ||
``` | ||
|
||
A `LocalTime` can be constructed from four components, hour, minute, second and nanosecond: | ||
A `LocalTime` can be constructed from four components, hour, minute, second, and nanosecond: | ||
```kotlin | ||
val knownTime = LocalTime(hour = 23, minute = 59, second = 12) | ||
val timeWithNanos = LocalTime(hour = 23, minute = 59, second = 12, nanosecond = 999) | ||
val hourMinute = LocalTime(hour = 12, minute = 13) | ||
``` | ||
|
||
### Converting instant to and from unix time | ||
### Converting instant to and from Unix time | ||
|
||
An `Instant` can be converted to a number of milliseconds since the Unix/POSIX epoch with the `toEpochMilliseconds()` function. | ||
To convert back, use the companion object function `Instant.fromEpochMilliseconds(Long)`. | ||
|
||
### Converting instant and local date/time to and from string | ||
|
||
Currently, `Instant`, `LocalDateTime`, `LocalDate` and `LocalTime` only support ISO-8601 format. | ||
Currently, `Instant`, `LocalDateTime`, `LocalDate`, and `LocalTime` only support ISO-8601 format. | ||
The `toString()` function is used to convert the value to a string in that format, and | ||
the `parse` function in companion object is used to parse a string representation back. | ||
the `parse` function in the companion object is used to parse a string representation back. | ||
|
||
|
||
```kotlin | ||
|
@@ -188,11 +188,11 @@ val instantBefore = Instant.parse("2010-06-01T22:19:44.475Z") | |
Alternatively, the `String.to...()` extension functions can be used instead of `parse`, | ||
where it feels more convenient: | ||
|
||
`LocalDateTime` uses a similar format, but without `Z` UTC time zone designator in the end. | ||
`LocalDateTime` uses a similar format, but without `Z` UTC time zone designator at the end. | ||
|
||
`LocalDate` uses a format with just year, month, and date components, e.g. `2010-06-01`. | ||
|
||
`LocalTime` uses a format with just hour, minute, second and (if non-zero) nanosecond components, e.g. `12:01:03`. | ||
`LocalTime` uses a format with just hour, minute, second, and (if non-zero) nanosecond components, e.g. `12:01:03`. | ||
|
||
```kotlin | ||
"2010-06-01T22:19:44.475Z".toInstant() | ||
|
@@ -240,7 +240,7 @@ val threeYearsAndAMonthLater = now.plus(DateTimePeriod(years = 3, months = 1), s | |
``` | ||
|
||
Note that `plus` and `...until` operations require a `TimeZone` as a parameter because the calendar interval between | ||
two particular instants can be different, when calculated in different time zones. | ||
two particular instants can be different when calculated in different time zones. | ||
|
||
### Date arithmetic | ||
|
||
|
@@ -253,7 +253,7 @@ Similar operations with date units are provided for `LocalDate` type: | |
|
||
Notice that, instead of the general `DateTimeUnit` and `DateTimePeriod` types, we're using their subtypes | ||
`DateTimeUnit.DateBased` and `DatePeriod` respectively. This allows preventing the situations when | ||
time components are being added to a date at compile time. | ||
time components are being added to date at compile time. | ||
|
||
### Date + time arithmetic | ||
|
||
|
@@ -284,7 +284,7 @@ val localDateTimeTwoDaysLater = instantTwoDaysLater.toLocalDateTime(timeZone) | |
|
||
## Implementation | ||
|
||
The implementation of date/time types, such as `Instant`, `LocalDateTime`, `TimeZone` and so on, relies on: | ||
The implementation of date/time types, such as `Instant`, `LocalDateTime`, `TimeZone`, and so on, relies on: | ||
|
||
- in JVM: [`java.time`](https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html) API; | ||
- in Js and Wasm-Js: [`js-joda`](https://js-joda.github.io/js-joda/) library; | ||
|
@@ -318,7 +318,7 @@ repositories { | |
} | ||
``` | ||
|
||
- In multiplatform projects, add a dependency to the commonMain source set dependencies | ||
- In multiplatform projects, add a dependency to the `commonMain` source set of dependencies | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the |
||
```kotlin | ||
kotlin { | ||
sourceSets { | ||
|
@@ -343,7 +343,7 @@ dependencies { | |
|
||
By default, there's only one time zone available in Kotlin/JS: the `SYSTEM` time zone with a fixed offset. | ||
|
||
If you want to use all time zones in Kotlin/JS platform, you need to add the following npm dependency: | ||
If you want to use all time zones in the Kotlin/JS platform, you need to add the following npm dependency: | ||
|
||
```kotlin | ||
kotlin { | ||
|
@@ -357,7 +357,7 @@ kotlin { | |
} | ||
``` | ||
|
||
and after that add the following initialization code in your project: | ||
and after that add the following initialization code to your project: | ||
|
||
```kotlin | ||
@JsModule("@js-joda/timezone") | ||
|
@@ -391,7 +391,7 @@ git submodule update | |
``` | ||
|
||
The project requires JDK 8 to build classes and to run tests. | ||
Gradle will try to find it among the installed JDKs or [provision](https://docs.gradle.org/current/userguide/toolchains.html#sec:provisioning) it automatically if it couldn't be found. | ||
Gradle will try to find it among the installed JDKs or [provision](https://docs.gradle.org/current/userguide/toolchains.html#sec:provisioning) automatically if it can't be found. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to reword as "[download] it automatically" |
||
The path to JDK 8 can be additionally specified with the environment variable `JDK_8`. | ||
For local builds, you can use a later version of JDK if you don't have that | ||
version installed. Specify the version of this JDK with the `java.mainToolchainVersion` Gradle property. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"a date" here means "an instance of LocalDate type"