named_timezones/named_timezones.rs
1// Copyright 2026 The android-chrono-tz Authors.
2// This project is dual-licensed under Apache 2.0 and MIT terms.
3// See LICENSE-APACHE and LICENSE-MIT for details.
4
5//! Example to try some named timezones.
6//!
7//! To run on an attached Android device:
8//!
9//! ```sh
10//! CARGO_NDK_PLATFORM=35 ANDROID_NDK_HOME=/usr/lib/android-ndk cargo ndk run --target aarch64-linux-android --example named_timezones
11//! ```
12
13use android_chrono_tz::Tz;
14use chrono::TimeZone;
15
16fn main() {
17 let timezone = Tz::new("Europe/London").unwrap();
18 println!("Timezone: {timezone:?}");
19 let summer = timezone.with_ymd_and_hms(2026, 4, 1, 0, 0, 0).unwrap();
20 println!("Summer time {summer}");
21 let winter = timezone.with_ymd_and_hms(2026, 3, 1, 0, 0, 0).unwrap();
22 println!("Winter time {winter}");
23
24 let local = Tz::local();
25 println!("Local timezone: {local:?}");
26}