# dromara/carbon

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/dromara-carbon).**

5,221 stars · 263 forks · Go · MIT

## Links

- GitHub: https://github.com/dromara/carbon
- Homepage: https://carbon.go-pkg.com
- awesome-repositories: https://awesome-repositories.com/repository/dromara-carbon.md

## Description

Carbon is a Go library for semantic date and time calculations, formatting, and parsing. It provides a semantic interface to simplify temporal data handling and improve the readability of date and time manipulations.

The library is distinguished by its support for multi-calendar date conversion, allowing transformations between Gregorian, Chinese Lunar, Persian, and Hebrew calendar systems. It also includes a localized temporal framework that uses ISO 639-1 codes to format dates and relative time differences across multiple language locales.

Additional capabilities cover global time zone management, the parsing of date strings via fuzzy templates and standard formats, and the calculation of relative time and meteorological seasons. For quality assurance, the project includes tools for deterministic time mocking to freeze the system clock during unit tests.

## Tags

### Data & Databases

- [Date and Time Libraries](https://awesome-repositories.com/f/data-databases/date-and-time-libraries.md) — Provides a semantic interface for parsing, validating, and manipulating date and time values. ([source](https://carbon.go-pkg.com/overview.html))
- [Localized Formatting](https://awesome-repositories.com/f/data-databases/date-and-time-libraries/localized-formatting.md) — Formats date and time output using ISO 639-1 language codes to support global languages. ([source](https://carbon.go-pkg.com/appendix/language-codes.html))
- [Date Object Creators](https://awesome-repositories.com/f/data-databases/date-and-time-libraries/relative-date-generations/date-object-creators.md) — Generates time objects from individual components like year, month, and day or from Unix timestamps. ([source](https://cdn.jsdelivr.net/gh/dromara/carbon@main/README.md))
- [Time Zone Management](https://awesome-repositories.com/f/data-databases/time-zone-management.md) — Handles time zone settings and performs conversions between different regional time offsets. ([source](https://carbon.go-pkg.com/overview.html))

### Software Engineering & Architecture

- [Temporal Type Wrappers](https://awesome-repositories.com/f/software-engineering-architecture/api-wrappers/standard-library-wrappers/temporal-type-wrappers.md) — Wraps standard library time types in a custom structure to provide a more expressive and readable API.
- [Temporal Translation Mappings](https://awesome-repositories.com/f/software-engineering-architecture/application-lifecycle-management/configuration-management/configuration-formats-and-schemas/yaml-configuration-files/locale-translation-files/temporal-translation-mappings.md) — Uses internal translation mappings to localize date and time strings into various languages. ([source](https://carbon.go-pkg.com/ja/overview.html))

### Part of an Awesome List

- [Date and Time](https://awesome-repositories.com/f/awesome-lists/productivity/date-and-time.md) — Provides a semantic interface for performing complex date and time calculations without external dependencies. ([source](https://carbon.go-pkg.com/))
- [Date And Time](https://awesome-repositories.com/f/awesome-lists/devtools/date-and-time.md) — Semantic and developer-friendly time package.

### Development Tools & Productivity

- [Cross-Calendar Conversions](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/calendar-date-calculations/cross-calendar-conversions.md) — Transforms dates between Gregorian, Chinese Lunar, Persian, and Hebrew calendar systems.
- [Inter-Calendar Transformations](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/calendar-date-calculations/inter-calendar-transformations.md) — Transforms dates between various systems including Julian, Chinese Lunar, Persian, and Hebrew calendars. ([source](https://carbon.go-pkg.com/usage/calendar.html))
- [Multi-Calendar Conversions](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/calendar-date-calculations/multi-calendar-conversions.md) — Enables transformations between Gregorian, Chinese Lunar, Persian, and Hebrew calendar systems.
- [Temporal Component Extractors](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/component-based-date-time-specifications/temporal-component-extractors.md) — Retrieves specific units of time such as years, months, days, or timestamps from a given date. ([source](https://carbon.go-pkg.com/overview.html))
- [Custom Date-Time Format Patterns](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/relative-date-formatting/custom-date-time-format-patterns.md) — Converts time objects into strings using semantic tokens for custom formatting of dates and time zones. ([source](https://carbon.go-pkg.com/appendix/format-signs.html))
- [Token-Based Templates](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/relative-date-formatting/custom-date-time-format-patterns/token-based-templates.md) — Uses alphanumeric tokens in format strings to map date components into custom output representations.
- [Date String Parsers](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/relative-date-formatting/date-string-parsers.md) — Converts date and time strings into usable objects using standard patterns and custom layouts. ([source](https://cdn.jsdelivr.net/gh/dromara/carbon@main/README.md))
- [Template-Based Date Parsing](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/relative-date-formatting/date-string-parsers/template-based-date-parsing.md) — Matches input strings against predefined or fuzzy patterns to resolve them into usable date objects.
- [Locale Mappings](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/relative-date-formatting/locale-mappings.md) — Uses lookup tables and ISO 639-1 codes to map temporal labels into different human languages.
- [Relative Date Generators](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/relative-date-generators.md) — Generates date objects for days preceding or following the current date using semantic shortcuts. ([source](https://carbon.go-pkg.com/usage/yesterday-today-tomorrow.html))
- [Date Localizations](https://awesome-repositories.com/f/development-tools-productivity/date-formatting-utilities/human-readable-formatters/date-localizations.md) — Supports the translation of date and time descriptions into multiple languages using ISO 639-1 locale settings.
- [Date Difference Calculators](https://awesome-repositories.com/f/development-tools-productivity/duration-formatters/duration-interval-calculators/date-difference-calculators.md) — Computes the duration between two time points and expresses results in human-readable or numeric units. ([source](https://carbon.go-pkg.com/usage/difference.html))
- [Relative Time Humanization](https://awesome-repositories.com/f/development-tools-productivity/localization-support/string-localization/relative-time-humanization.md) — Expresses the difference between two dates as human-readable relative time strings across multiple locales. ([source](https://cdn.jsdelivr.net/gh/dromara/carbon@main/README.md))
- [Time Freezing Utilities](https://awesome-repositories.com/f/development-tools-productivity/current-time-retrievals/time-freezing-utilities.md) — Locks the system clock to a constant value to ensure deterministic results in unit tests. ([source](https://cdn.jsdelivr.net/gh/dromara/carbon@main/README.md))
- [Global Defaults](https://awesome-repositories.com/f/development-tools-productivity/global-defaults.md) — Enables setting global defaults for timezones, language locales, and weekend definitions. ([source](https://carbon.go-pkg.com/usage/default.html))
- [String Localization](https://awesome-repositories.com/f/development-tools-productivity/localization-support/string-localization.md) — Provides mechanisms for retrieving and formatting localized time and date components. ([source](https://carbon.go-pkg.com/ko/overview.html))

### Programming Languages & Runtimes

- [Time Zone Converters](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/date-and-time-utilities/time-zone-converters.md) — Provides functions to set, retrieve, and convert time instances between different geographical time zones. ([source](https://carbon.go-pkg.com/ja/overview.html))
- [Standard Time Formatters](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/date-and-time-utilities/time-zone-converters/standard-time-formatters.md) — Converts time objects into standards like ISO8601 and RFC series for display and transmission. ([source](https://carbon.go-pkg.com/overview.html))

### Scientific & Mathematical Computing

- [Multi-Calendar Converters](https://awesome-repositories.com/f/scientific-mathematical-computing/calendar-logic-utilities/multi-calendar-converters.md) — Implements mathematical algorithms to convert Gregorian dates into lunar, Persian, or Hebrew calendar systems.

### User Interface & Experience

- [Localized Calendar Labels](https://awesome-repositories.com/f/user-interface-experience/localized-calendar-labels.md) — Translates calendar-related labels such as months, weeks, and seasons into multiple supported languages. ([source](https://carbon.go-pkg.com/usage/i18n.html))

### Web Development

- [Date and Time Formatting](https://awesome-repositories.com/f/web-development/date-and-time-formatting.md) — Converts time strings into objects and outputs them in ISO and RFC standards. ([source](https://carbon.go-pkg.com/ko/overview.html))
- [Internationalized Date Formatting](https://awesome-repositories.com/f/web-development/internationalized-date-formatting.md) — Provides locale-aware formatting to convert date and time objects into human-readable strings.
- [Global Configuration](https://awesome-repositories.com/f/web-development/global-configuration.md) — Provides a centralized configuration system to synchronize default timezones and locales across the application.

### Security & Cryptography

- [Deterministic Testing Clocks](https://awesome-repositories.com/f/security-cryptography/clock-abstracted-time-validation/deterministic-testing-clocks.md) — Decouples time measurement from the system clock to enable reproducible Go unit tests.

### Testing & Quality Assurance

- [System Clock Mocks](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/dependency-mocking/timer-mocks/database-timestamp-mocks/system-clock-mocks.md) — Allows freezing the system clock with a fixed timestamp to ensure deterministic behavior during unit tests.
- [Time Simulation Utilities](https://awesome-repositories.com/f/testing-quality-assurance/time-simulation-utilities.md) — Intercepts native timing functions to simulate a fixed clock for subsequent date operations. ([source](https://carbon.go-pkg.com/usage/test.html))
