{"id":13407060,"url":"https://github.com/Kotlin/kotlinx-datetime","last_synced_at":"2025-03-14T11:30:58.246Z","repository":{"id":37783922,"uuid":"215849579","full_name":"Kotlin/kotlinx-datetime","owner":"Kotlin","description":"KotlinX multiplatform date/time library","archived":false,"fork":false,"pushed_at":"2024-10-23T09:03:57.000Z","size":1427,"stargazers_count":2414,"open_issues_count":78,"forks_count":101,"subscribers_count":63,"default_branch":"master","last_synced_at":"2024-10-29T15:09:23.247Z","etag":null,"topics":["date","datetime","kotlin","timezone"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kotlin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-17T17:33:02.000Z","updated_at":"2024-10-29T01:27:36.000Z","dependencies_parsed_at":"2024-03-11T20:31:39.829Z","dependency_job_id":"5f13e35e-ecef-42a5-9c96-6b83e8118ae0","html_url":"https://github.com/Kotlin/kotlinx-datetime","commit_stats":{"total_commits":279,"total_committers":25,"mean_commits":11.16,"dds":0.5448028673835126,"last_synced_commit":"bc8adee2b9e3659e8e1c38fc09f3a4a1bdf85276"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fkotlinx-datetime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fkotlinx-datetime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fkotlinx-datetime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fkotlinx-datetime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kotlin","download_url":"https://codeload.github.com/Kotlin/kotlinx-datetime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243569295,"owners_count":20312393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","datetime","kotlin","timezone"],"created_at":"2024-07-30T20:00:18.852Z","updated_at":"2025-03-14T11:30:58.234Z","avatar_url":"https://github.com/Kotlin.png","language":"Kotlin","funding_links":[],"categories":["Libraries","Kotlin"],"sub_categories":["Utility","⏰ Date-Time"],"readme":"# kotlinx-datetime\n\n[![Kotlin Alpha](https://kotl.in/badges/alpha.svg)](https://kotlinlang.org/docs/components-stability.html)\n[![JetBrains official project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub) \n[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)\n[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-datetime.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:org.jetbrains.kotlinx%20AND%20a:kotlinx-datetime)\n[![Kotlin](https://img.shields.io/badge/kotlin-1.9.21-blue.svg?logo=kotlin)](http://kotlinlang.org)\n[![KDoc link](https://img.shields.io/badge/API_reference-KDoc-blue)](https://kotlinlang.org/api/kotlinx-datetime/)\n[![Slack channel](https://img.shields.io/badge/chat-slack-blue.svg?logo=slack)](https://kotlinlang.slack.com/messages/kotlinx-datetime/)\n[![TeamCity build](https://img.shields.io/teamcity/build/s/KotlinTools_KotlinxDatetime_Build_All.svg?server=http%3A%2F%2Fteamcity.jetbrains.com)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=KotlinTools_KotlinxDatetime_Build_All\u0026guest=1)\n\nA multiplatform Kotlin library for working with date and time.\n\nSee [Using in your projects](#using-in-your-projects) for the instructions how to setup a dependency in your project.\n\n## Design overview\n\nThere are a few guiding principles in the design of `kotlinx-datetime`. First of all, it is pragmatic, focused\non the most common problems developers face every day (pun intended) when working with dates and times. It is not\nall-encompassing and lacks some domain-specific utilities that special-purpose applications might need.\nWe chose convenience over generality, so the API surface this library provides is as minimal as possible\nto meet the use-cases.\n\nThe library puts a clear boundary between the physical time of an instant and the local, time-zone dependent \ncivil time, consisting of components such as year, month, etc that people use when talking about time. \nWe intentionally avoid entities in the library that mix both together and could be misused.\nHowever, there are convenience operations that take, for example, a physical instant and perform a calendar-based \nadjustment (such as adding a month); all such operations\nexplicitly take a time-zone information as parameter to clearly state that their result depends on the civil time-zone\nrules which are subject to change at any time.\n\nThe library is based on the ISO 8601 international standard, other ways to represent dates and times are out of\nits scope. Internationalization (such as locale-specific month and day names) is out the scope, too. \n\n## Types\n\nThe library provides a basic set of types for working with date and time:\n\n- `Instant` to represent a moment on the UTC-SLS time scale;\n- `Clock` to obtain the current instant;\n- `LocalDateTime` to represent date and time components without a reference to the particular time zone; \n- `LocalDate` to represent the components of date only;\n- `LocalTime` to represent the components of time only;\n- `TimeZone` and `FixedOffsetTimeZone` provide time zone information to convert between `Instant` and `LocalDateTime`;\n- `Month` and `DayOfWeek` enums;\n- `DateTimePeriod` to represent a difference between two instants decomposed into date and time units;\n- `DatePeriod` is a subclass of `DateTimePeriod` with zero time components,\nit represents a difference between two LocalDate values decomposed into date units.\n- `DateTimeUnit` provides a set of predefined date and time units to use in arithmetic operations on `Instant` and `LocalDate`. \n- `UtcOffset` represents the amount of time the local datetime at a particular time zone differs from the datetime at UTC.\n\n### Type use-cases\n\nHere is some basic advice on how to choose which of the date-carrying types to use in what cases:\n\n- Use `Instant` to represent a timestamp of the event that had already happened in the past (like a timestamp of \n  a log entry) or will definitely happen in a well-defined instant of time in the future not far away from now \n  (like an order confirmation deadline in 1 hour from now).\n  \n- Use `LocalDateTime` to represent a time of the event that is scheduled to happen in the far future at a certain \n  local time (like a scheduled meeting in a few months from now). You'll have to keep track of the `TimeZone` of \n  the scheduled event separately. Try to avoid converting future events to `Instant` in advance, because time-zone \n  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 \n  a good idea to use `Instant` everywhere.\n  \n  Also, use `LocalDateTime` to decode an `Instant` to its local datetime components for display and UIs.\n  \n- Use `LocalDate` to represent the date of an event that does not have a specific time associated with it (like a birth date).\n\n- Use `LocalTime` to represent the time of an event that does not have a specific date associated with it.\n \n## Operations\n\nWith the above types you can get the following operations done.\n\n\n### Getting the current moment of time\n\nThe current moment of time can be captured with the `Instant` type. \nTo obtain an `Instant` corresponding to the current moment of time, \nuse `now()` function of the `Clock` interface:\n\n```kotlin\nval clock: Clock = ...\nval currentMoment = clock.now()\n```\n\nAn instance of `Clock` can be injected through the function/class parameters, \nor you can use its default implementation `Clock.System` that represents the system clock:\n\n```kotlin\nval currentMoment = Clock.System.now()\n```\n\n\n### Converting an instant to local date and time components\n\nAn `Instant` is just a counter of high resolution time intervals since the beginning of time scale.\nTo get human readable components from an `Instant` value, you need to convert it to the `LocalDateTime`\ntype that represents date and time components without a reference to the particular time zone.\n\nThe `TimeZone` type provides the rules to convert instants from and to datetime components.\n\n```kotlin\nval currentMoment: Instant = Clock.System.now()\nval datetimeInUtc: LocalDateTime = currentMoment.toLocalDateTime(TimeZone.UTC)\nval datetimeInSystemZone: LocalDateTime = currentMoment.toLocalDateTime(TimeZone.currentSystemDefault())\n```\n\nA `LocalDateTime` instance exposes familiar components of the Gregorian calendar: \n`year`, `month`, `dayOfMonth`, `hour`, and so on up to `nanosecond`.\nThe property `dayOfWeek` shows what weekday that date is,\nand `dayOfYear` shows the day number since the beginning of a year.\n\n\nAdditional time zones can be acquired by their string identifier with the `TimeZone.of(id: String)` function.\n```kotlin\nval tzBerlin = TimeZone.of(\"Europe/Berlin\")\nval datetimeInBerlin = currentMoment.toLocalDateTime(tzBerlin)\n```\n\nA `LocalDateTime` instance can be constructed from individual components:\n\n```kotlin\nval kotlinReleaseDateTime = LocalDateTime(2016, 2, 15, 16, 57, 0, 0)\n```\n\nAn instant can be obtained from `LocalDateTime` by interpreting it as a time moment\nin a particular `TimeZone`:\n\n```kotlin\nval kotlinReleaseInstant = kotlinReleaseDateTime.toInstant(TimeZone.of(\"UTC+3\"))\n```\n\n### Getting local date components\n\nA `LocalDate` represents a local date without time. You can obtain one from an `Instant`\nby converting it to `LocalDateTime` and taking its `date` property.\n\n```kotlin\nval now: Instant = Clock.System.now()\nval today: LocalDate = now.toLocalDateTime(TimeZone.currentSystemDefault()).date\n// or shorter\nval today: LocalDate = Clock.System.todayIn(TimeZone.currentSystemDefault())\n```\nNote, that today's date really depends on the time zone in which you're observing the current moment.\n\n`LocalDate` can be constructed from three components, year, month, and day:\n```kotlin\nval knownDate = LocalDate(2020, 2, 21)\n```\n\n### Getting local time components\n\nA `LocalTime` represents local time without date. You can obtain one from an `Instant`\nby converting it to `LocalDateTime` and taking its `time` property.\n\n```kotlin\nval now: Instant = Clock.System.now()\nval thisTime: LocalTime = now.toLocalDateTime(TimeZone.currentSystemDefault()).time\n```\n\nA `LocalTime` can be constructed from four components, hour, minute, second and nanosecond:\n```kotlin\nval knownTime = LocalTime(hour = 23, minute = 59, second = 12)\nval timeWithNanos = LocalTime(hour = 23, minute = 59, second = 12, nanosecond = 999)\nval hourMinute = LocalTime(hour = 12, minute = 13)\n```\n\n### Converting instant to and from unix time\n\nAn `Instant` can be converted to a number of milliseconds since the Unix/POSIX epoch with the `toEpochMilliseconds()` function.\nTo convert back, use the companion object function `Instant.fromEpochMilliseconds(Long)`.\n\n### Converting instant and local datetime to and from the ISO 8601 string\n\n`Instant`, `LocalDateTime`, `LocalDate` and `LocalTime` provide shortcuts for\nparsing and formatting them using the extended ISO 8601 format.\nThe `toString()` function is used to convert the value to a string in that format, and \nthe `parse` function in companion object is used to parse a string representation back. \n\n```kotlin\nval instantNow = Clock.System.now()\ninstantNow.toString()  // returns something like 2015-12-31T12:30:00Z\nval instantBefore = Instant.parse(\"2010-06-01T22:19:44.475Z\")\n```\n\n`LocalDateTime` uses a similar format, but without `Z` UTC time zone designator in the end.\n\n`LocalDate` uses a format with just year, month, and date components, e.g. `2010-06-01`.\n\n`LocalTime` uses a format with just hour, minute, second and (if non-zero) nanosecond components, e.g. `12:01:03`.\n\n```kotlin\nLocalDateTime.parse(\"2010-06-01T22:19:44\")\nLocalDate.parse(\"2010-06-01\")\nLocalTime.parse(\"12:01:03\")\nLocalTime.parse(\"12:00:03.999\")\nLocalTime.parse(\"12:0:03.999\") // fails with an IllegalArgumentException\n```\n\n### Working with other string formats\n\nWhen some data needs to be formatted in some format other than ISO 8601, one\ncan define their own format or use some of the predefined ones:\n\n```kotlin\n// import kotlinx.datetime.format.*\n\nval dateFormat = LocalDate.Format {\n    monthNumber(padding = Padding.SPACE)\n    char('/')\n    dayOfMonth()\n    char(' ')\n    year()\n}\n\nval date = dateFormat.parse(\"12/24 2023\")\nprintln(date.format(LocalDate.Formats.ISO_BASIC)) // \"20231224\"\n```\n\n#### Using Unicode format strings (like `yyyy-MM-dd`)\n\nGiven a constant format string like the ones used by Java's\n[DateTimeFormatter.ofPattern](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html) can be\nconverted to Kotlin code using the following invocation:\n\n```kotlin\n// import kotlinx.datetime.format.*\n\nprintln(DateTimeFormat.formatAsKotlinBuilderDsl(DateTimeComponents.Format {\n    byUnicodePattern(\"uuuu-MM-dd'T'HH:mm:ss[.SSS]Z\")\n}))\n\n// will print:\n/*\ndate(LocalDate.Formats.ISO)\nchar('T')\nhour()\nchar(':')\nminute()\nchar(':')\nsecond()\nalternativeParsing({\n}) {\n    char('.')\n    secondFraction(3)\n}\noffset(UtcOffset.Formats.FOUR_DIGITS)\n */\n```\n\nWhen your format string is not constant, with the `FormatStringsInDatetimeFormats` opt-in,\nyou can use the format without converting it to Kotlin code beforehand:\n\n```kotlin\nval formatPattern = \"yyyy-MM-dd'T'HH:mm:ss[.SSS]\"\n\n@OptIn(FormatStringsInDatetimeFormats::class)\nval dateTimeFormat = LocalDateTime.Format {\n    byUnicodePattern(formatPattern)\n}\n\ndateTimeFormat.parse(\"2023-12-24T23:59:59\")\n```\n\n### Parsing and formatting partial, compound or out-of-bounds data\n\nSometimes, the required string format doesn't fully correspond to any of the\nclasses `kotlinx-datetime` provides. In these cases, `DateTimeComponents`, a\ncollection of all datetime fields, can be used instead.\n\n```kotlin\n// import kotlinx.datetime.format.*\n\nval yearMonth = DateTimeComponents.Format { year(); char('-'); monthNumber() }\n    .parse(\"2024-01\")\nprintln(yearMonth.year)\nprintln(yearMonth.monthNumber)\n\nval dateTimeOffset = DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET\n    .parse(\"2023-01-07T23:16:15.53+02:00\")\nprintln(dateTimeOffset.toUtcOffset()) // +02:00\nprintln(dateTimeOffset.toLocalDateTime()) // 2023-01-07T23:16:15.53\n```\n\nOccasionally, one can encounter strings where the values are slightly off:\nfor example, `23:59:60`, where `60` is an invalid value for the second.\n`DateTimeComponents` allows parsing such values as well and then mutating them\nbefore conversion.\n\n```kotlin\nval time = DateTimeComponents.Format { time(LocalTime.Formats.ISO) }\n    .parse(\"23:59:60\").apply {\n        if (second == 60) second = 59\n    }.toLocalTime()\nprintln(time) // 23:59:59\n```\n\nBecause `DateTimeComponents` is provided specifically for parsing and\nformatting, there is no way to construct it normally. If one needs to format\npartial, complex or out-of-bounds data, the `format` function allows building\n`DateTimeComponents` specifically for formatting it:\n\n```kotlin\nDateTimeComponents.Formats.RFC_1123.format {\n    // the receiver of this lambda is DateTimeComponents\n    setDate(LocalDate(2023, 1, 7))\n    hour = 23\n    minute = 59\n    second = 60\n    setOffset(UtcOffset(hours = 2))\n} // Sat, 7 Jan 2023 23:59:60 +0200\n```\n\n### Instant arithmetic\n\n```kotlin\nval now = Clock.System.now()\nval instantInThePast: Instant = Instant.parse(\"2020-01-01T00:00:00Z\")\nval durationSinceThen: Duration = now - instantInThePast\nval equidistantInstantInTheFuture: Instant = now + durationSinceThen\n```\n\n`Duration` is a type from the experimental `kotlin.time` package in the Kotlin standard library.\nThis type holds the amount of time that can be represented in different time units: from nanoseconds to 24H days.\n\nTo get the calendar difference between two instants you can use the `Instant.periodUntil(Instant, TimeZone)` function.\n\n```kotlin\nval period: DateTimePeriod = instantInThePast.periodUntil(Clock.System.now(), TimeZone.UTC)\n```\n\nA `DateTimePeriod` represents a difference between two particular moments as a sum of calendar components, \nlike \"2 years, 3 months, 10 days, and 22 hours\".\n\nThe difference can be calculated as an integer amount of specified date or time units:\n\n```kotlin\nval diffInMonths = instantInThePast.until(Clock.System.now(), DateTimeUnit.MONTH, TimeZone.UTC)\n```\nThere are also shortcuts `yearsUntil(...)`, `monthsUntil(...)`, and `daysUntil(...)`.\n\nA particular amount of datetime units or a datetime period can be added to an `Instant` with the `plus` function:\n\n```kotlin\nval now = Clock.System.now()\nval systemTZ = TimeZone.currentSystemDefault()\nval tomorrow = now.plus(2, DateTimeUnit.DAY, systemTZ)\nval threeYearsAndAMonthLater = now.plus(DateTimePeriod(years = 3, months = 1), systemTZ)\n```\n\nNote that `plus` and `...until` operations require a `TimeZone` as a parameter because the calendar interval between \ntwo particular instants can be different, when calculated in different time zones.\n\n### Date arithmetic\n\nSimilar operations with date units are provided for `LocalDate` type:\n\n- `LocalDate.plus(number, DateTimeUnit.DateBased)`\n- `LocalDate.plus(DatePeriod)`\n- `LocalDate.until(LocalDate, DateTimeUnit.DateBased)` and the shortcuts `yearsUntil`, `monthUntil`, `daysUntil`\n- `LocalDate.periodUntil(LocalDate): DatePeriod` and `LocalDate.minus(LocalDate): DatePeriod`\n\nNotice that, instead of the general `DateTimeUnit` and `DateTimePeriod` types, we're using their subtypes\n`DateTimeUnit.DateBased` and `DatePeriod` respectively. This allows preventing the situations when\ntime components are being added to a date at compile time.\n\n### Date + time arithmetic\n\nArithmetic on `LocalDateTime` is intentionally omitted. The reason for this is that the presence of daylight saving time\ntransitions (changing from standard time to daylight saving time and back) causes `LocalDateTime` arithmetic to be\nill-defined. For example, consider time gaps (or, as [`dst` tag wiki on Stack Overflow](https://stackoverflow.com/tags/dst/info)\ncalls them, \"spring forward\" transitions), that is, ranges of date + time combinations that never occur in a given\ntime zone due to clocks moving forward. If we allowed `LocalDateTime` arithmetic that ignored time zones, then it\ncould result in `LocalDateTime` instances that are inside a time gap and are invalid in the implied time zone.\n\nTherefore, the recommended way to use a `LocalDateTime` is to treat it as a representation of an `Instant`,\nperform all the required arithmetic on `Instant` values, and only convert to `LocalDateTime` when a human-readable\nrepresentation is needed.\n\n```kotlin\nval timeZone = TimeZone.of(\"Europe/Berlin\")\nval localDateTime = LocalDateTime.parse(\"2021-03-27T02:16:20\")\nval instant = localDateTime.toInstant(timeZone)\n\nval instantOneDayLater = instant.plus(1, DateTimeUnit.DAY, timeZone)\nval localDateTimeOneDayLater = instantOneDayLater.toLocalDateTime(timeZone)\n// 2021-03-28T03:16:20, as 02:16:20 that day is in a time gap\n\nval instantTwoDaysLater = instant.plus(2, DateTimeUnit.DAY, timeZone)\nval localDateTimeTwoDaysLater = instantTwoDaysLater.toLocalDateTime(timeZone)\n// 2021-03-29T02:16:20\n```\n\n## Implementation\n\nThe implementation of datetime types, such as `Instant`, `LocalDateTime`, `TimeZone` and so on, relies on:\n\n- in JVM: [`java.time`](https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html) API;\n- in Js and Wasm-Js: [`js-joda`](https://js-joda.github.io/js-joda/) library;\n- in Native: based on the [ThreeTen backport project](https://www.threeten.org/threetenbp/)\n  - time zone support is provided by [date](https://github.com/HowardHinnant/date/) C++ library;\n\n## Known/open issues, work TBD\n\n- [x] Some kind of `Clock` interface is needed as a pluggable replacement for `Instant.now()`.\n- [ ] Flexible locale-neutral parsing and formatting facilities are needed to support various datetime interchange\n  formats that are used in practice (in particular, various RFCs).\n\n## Using in your projects\n\n\u003e Note that the library is experimental, and the API is subject to change.\n\nThe library is published to Maven Central.\n\nThe library is compatible with the Kotlin Standard Library not lower than `1.9.0`.\n\nIf you target Android devices running **below API 26**, you need to use Android Gradle plugin 4.0 or newer \nand enable [core library desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring).\n\n### Gradle\n\n- Add the Maven Central repository if it is not already there:\n\n```kotlin\nrepositories {\n    mavenCentral()\n}\n```\n\n- In multiplatform projects, add a dependency to the commonMain source set dependencies\n```kotlin\nkotlin {\n    sourceSets {\n        commonMain {\n             dependencies {\n                 implementation(\"org.jetbrains.kotlinx:kotlinx-datetime:0.6.2\")\n             }\n        }\n    }\n}\n```\n\n- To use the library in a single-platform project, add a dependency to the dependencies block.\n\n```groovy\ndependencies {\n    implementation(\"org.jetbrains.kotlinx:kotlinx-datetime:0.6.2\")\n}\n```\n\n#### Note about time zones in JS\n\nBy default, there's only one time zone available in Kotlin/JS: the `SYSTEM` time zone with a fixed offset.\n\nIf you want to use all time zones in Kotlin/JS platform, you need to add the following npm dependency:\n\n```kotlin\nkotlin {\n    sourceSets {\n        val jsMain by getting {\n            dependencies {\n                implementation(npm(\"@js-joda/timezone\", \"2.3.0\"))\n            }\n        }\n    }\n}\n```\n\nand after that add the following initialization code in your project:\n\n```kotlin\n@JsModule(\"@js-joda/timezone\")\n@JsNonModule\nexternal object JsJodaTimeZoneModule\n\nprivate val jsJodaTz = JsJodaTimeZoneModule\n```\n\n#### Note about time zones in Wasm/JS\n\nWasm/JS uses the same time zone support as JS, so almost the same instructions apply.\n\nIn your Gradle build script, add the following dependency:\n\n```kotlin\nkotlin {\n    sourceSets {\n        val wasmJsMain by getting {\n            dependencies {\n                implementation(npm(\"@js-joda/timezone\", \"2.3.0\"))\n            }\n        }\n    }\n}\n```\n\nand after that add the following initialization code in your project:\n\n```kotlin\n@JsModule(\"@js-joda/timezone\")\nexternal object JsJodaTimeZoneModule\n\nprivate val jsJodaTz = JsJodaTimeZoneModule\n```\n\n#### Note about time zones in Wasm/WASI\n\nBy default, there's only one time zone available in Kotlin/Wasm WASI: the `UTC` time zone with a fixed offset.\n\nIf you want to use all time zones in Kotlin/Wasm WASI platform, you need to add the following dependency:\n\n```kotlin\nkotlin {\n    sourceSets {\n        val wasmWasiMain by getting {\n            dependencies {\n                implementation(\"kotlinx-datetime-zoneinfo\", \"2025a-spi.0.6.2\")\n            }\n        }\n    }\n}\n```\n\n### Maven\n\nAdd a dependency to the `\u003cdependencies\u003e` element. Note that you need to use the platform-specific `-jvm` artifact in Maven.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.jetbrains.kotlinx\u003c/groupId\u003e\n    \u003cartifactId\u003ekotlinx-datetime-jvm\u003c/artifactId\u003e\n    \u003cversion\u003e0.6.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Building\n\nThe project requires JDK 8 to build classes and to run tests. \nGradle 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.\nThe path to JDK 8 can be additionally specified with the environment variable `JDK_8`. \nFor local builds, you can use a later version of JDK if you don't have that \nversion installed. Specify the version of this JDK with the `java.mainToolchainVersion` Gradle property.\n\nAfter that, the project can be opened in IDEA and built with Gradle.\n\nFor building and running benchmarks, see [README.md](benchmarks/README.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKotlin%2Fkotlinx-datetime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKotlin%2Fkotlinx-datetime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKotlin%2Fkotlinx-datetime/lists"}