Crates.io | timekit |
lib.rs | timekit |
version | 0.1.1 |
source | src |
created_at | 2024-10-10 16:15:00.995338 |
updated_at | 2024-10-11 00:45:14.933501 |
description | A simple Rust library for working with timezones and displaying current time in multiple zones. |
homepage | https://statpan.com |
repository | https://github.com/yourusername/timekit |
max_upload_size | |
id | 1403968 |
size | 29,604 |
TimeKit
is a simple and lightweight Rust library for working with timezones and displaying the current date and time in multiple time zones. This library is designed to be easy to use and efficient, providing hardcoded timezone offsets to avoid runtime computation and enhance performance.
The purpose of TimeKit
is to offer a flexible and convenient way to work with different time zones in Rust, allowing developers to retrieve and display the current time in a variety of world time zones. This project was built to address the need for a lightweight timezone-handling library without external dependencies, focusing on simplicity and usability.
In the globalized world we live in, applications often need to support users in different regions. Having a reliable and efficient method to calculate time across multiple time zones is essential for many systems, including scheduling applications, communication tools, and data logging systems.
YYYY-MM-DD HH:MM:SS
format.To start using TimeKit
, add the following line to your Cargo.toml
file under [dependencies]
:
[dependencies]
timekit = "0.1.0" # Adjust to the latest version
Then, in your Rust code:
use timekit;
Here's a simple example showing how to use TimeKit to get the current time in various time zones.
use timekit::TimeZone;
use timekit::now;
fn main() {
// Get the current time in UTC
let utc_time = now(TimeZone::UTC);
println!("Current UTC time: {}", utc_time);
// Get the current time in Korea Standard Time (KST)
let kst_time = now(TimeZone::KST);
println!("Current KST time: {}", kst_time);
// Get the current time in Eastern Standard Time (EST)
let est_time = now(TimeZone::EST);
println!("Current EST time: {}", est_time);
}
TimeKit supports a wide variety of time zones. Here are some of the supported zones:
UTC: Coordinated Universal Time (UTC+0)
KST: Korea Standard Time (UTC+9)
EST: Eastern Standard Time (UTC-5)
PST: Pacific Standard Time (UTC-8)
JST: Japan Standard Time (UTC+9)
IST: India Standard Time (UTC+5:30)
CET: Central European Time (UTC+1)
AST: Atlantic Standard Time (UTC-4)
CST: Central Standard Time (UTC-6)
MST: Mountain Standard Time (UTC-7)
AKST: Alaska Standard Time (UTC-9)
HST: Hawaii Standard Time (UTC-10)
BST: British Summer Time (UTC+1)
WET: Western European Time (UTC+0)
EET: Eastern European Time (UTC+2)
SAST: South Africa Standard Time (UTC+2)
EAT: East Africa Time (UTC+3)
AEST: Australian Eastern Standard Time (UTC+10)
ACST: Australian Central Standard Time (UTC+9:30)
AWST: Australian Western Standard Time (UTC+8)
CST (Asia): China Standard Time (UTC+8)
SGT: Singapore Time (UTC+8)
HKT: Hong Kong Time (UTC+8)