tz
tz is a powerful Dart package designed to simplify the calculate time differences, and manage daylight saving time changes.
Features
- Timezone Support: Easily convert between different timezones.
- Offset Handling: Manage and apply time offsets to datetime objects.
Installation
dart pub add tz
Usage
import 'package:tz/tz.dart';
void main() {
final timezone = Timezone('America/New_York');
final now = DateTime.timestamp();
final offset = timezone.offset(now);
final time = now.add(Duration(milliseconds: offset));
print("It's $time in New York.");
}
Contributing
- Install Node 20 (for compiling timezone data)
- Install Java 11 (for tests)
- Run
dart pub getto install dependencies - Run
dart run ./tool/prepare.dartto generate the timezone data