worldtime

Creator: coderz1093

Last updated:

Add to Cart

Description:

worldtime

1.2.0 #
A Flutter package to get the time of a specific time zone or geo location.
It also includes an easy to use formatter for DateTime with customizable formatting.
Comes with built-in extensions for time frame comparison.
Features #

Get current time from EZ Time Zone
Get current time from Latitude and Longitude
Format a Flutter DateTime object to a pretty String formatted text to your liking
Check if a date compared to another is in the same timezone, year, month, week, day, hour or
minute


Short example code #
import 'package:worldtime/worldtime.dart';

final _worldtimePlugin = Worldtime();

final String myFormatter = 'time - \\h:\\m, date - \\D/\\M/\\Y';

final DateTime timeAmsterdamTZ = await _worldtimePlugin
.timeByCity('Europe/Amsterdam');

final DateTime timeAmsterdamGeo = await _worldtimePlugin
.timeByLocation(latitude: 52.3676, longitude: 4.9041);

final String resultTZ = _worldtimePlugin
.format(dateTime: timeAmsterdamTZ, formatter: myFormatter);

final String resultGeo = _worldtimePlugin
.format(dateTime: timeAmsterdamGeo, formatter: myFormatter);
copied to clipboard
Walk through #
Import the plugin
import 'package:worldtime/worldtime.dart';
copied to clipboard
Initiate the plugin
final _worldtimePlugin = Worldtime();
copied to clipboard
Create a formatter.
final String myFormatter = 'time - \\h:\\m, date - \\D/\\M/\\Y';
copied to clipboard
Example with TZ Time Zone #
Get the time in Amsterdam.
final DateTime timeAmsterdamTZ = await _worldtimePlugin
.timeByCity('Europe/Amsterdam');
copied to clipboard
Get and store the value:
final String resultTZ = _worldtimePlugin
.format(dateTime: timeAmsterdamTZ,formatter:myFormatter);
copied to clipboard
Example with Coordinates #
Amsterdam's coordinates are:
52.3676° N, 4.9041° E => latitude: 52.3676, longitude: 4.9041
Get the time in Amsterdam's coordinates.
final DateTime timeAmsterdamGeo = await _worldtimePlugin.
timeByLocation(
latitude: 52.3676,
longitude: 4.9041,
);
copied to clipboard
We will use the same formatter. ('time - \h:\m, date - \D/\M/\Y')
Get and store the value:
final String resultGeo = _worldtimePlugin.
format(
dateTime: timeAmsterdamGeo,
formatter:myFormatter,
);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.