lat_lng_to_timezone 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 45

LatLongToTimezone #

Lat/long to timezone mapper in Dart. Does not require web services or data files

The "lat/long to timezone polygon mapping" is hardcoded, and we hope this rarely changes, but the changes to offsets and daylight savings changeover dates etc. (which are more frequent) are taken care of by your system libraries and so these are automatically kept up-to-date. From time to time, someone updates the files with the latest timezone polygons, but these rarely change...I think the most recent change is the Crimean peninsular.

This Dart library is port of the original project
available at https://github.com/drtimcooper/LatLongToTimezone. Ported it to Dart to make it easily available on pub.dev. In order to support updates from the upstream version, the formatting was changed as little as possible (specifically not adding control flow braces or truncating lines at 80 characters).

Usage #

See the example at pub.dev.

CHANGELOG.md

0.1.2 2020-05-20 #

  • Update README to point to pub.dev for example

0.1.1 2020-05-20 #

  • Fix example

0.1.0 2020-05-20 #

  • Initial version

example/example.dart

import 'package:lat_lng_to_timezone/lat_lng_to_timezone.dart' as tzmap;

void main() {
  // Montreal coordinates
  double latitude = 45.5017;
  double longitude = -73.5673;

  String tz = tzmap.latLngToTimezoneString(latitude, longitude);
  print('Montreal is in the $tz time zone.');
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  lat_lng_to_timezone: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:lat_lng_to_timezone/lat_lng_to_timezone.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
4
Health:
Code health derived from static analysis. [more]
75
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

We analyzed this package on Jul 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Health suggestions

Fix lib/src/lat_lng_to_timezone.dart. (-25 points)

Analysis of lib/src/lat_lng_to_timezone.dart reported 5481 hints, including:

line 5 col 1: Prefer using /// for doc comments.

line 445 col 24: DO use curly braces for all flow control structures.

line 445 col 46: DO use curly braces for all flow control structures.

line 445 col 67: DO use curly braces for all flow control structures.

line 445 col 90: DO use curly braces for all flow control structures.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0