Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding time zone handling #199

Closed
MrCsabaToth opened this issue Aug 28, 2021 · 5 comments
Closed

Adding time zone handling #199

MrCsabaToth opened this issue Aug 28, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@MrCsabaToth
Copy link
Member

UA and Training Peaks requires time zone designation

@MrCsabaToth MrCsabaToth added the enhancement New feature or request label Aug 28, 2021
@MrCsabaToth MrCsabaToth self-assigned this Aug 28, 2021
@MrCsabaToth
Copy link
Member Author

MrCsabaToth commented Aug 28, 2021

For now I won't use .toUtc(), .toLocal(), or fromMillisecondsSinceEpoch(..., isUtc: true). Here are some DaartPad experiments:

  final now = DateTime.now();
  debugPrint("now $now");
  final epoch = now.millisecondsSinceEpoch;
  debugPrint("epoch $epoch");
  final dt = DateTime.fromMillisecondsSinceEpoch(epoch);
  debugPrint("dt $dt");
  final utcDt = DateTime.fromMillisecondsSinceEpoch(epoch, isUtc: true);
  debugPrint("utcDt $utcDt");

  final utcNow = now.toUtc();
  debugPrint("UTC Now $utcNow");
  final utcEpoch = utcNow.millisecondsSinceEpoch;
  debugPrint("UTC epoch $utcEpoch");
  final dtUtc = DateTime.fromMillisecondsSinceEpoch(utcEpoch);
  debugPrint("dt UTC $dtUtc");
  final utcDtUtc = DateTime.fromMillisecondsSinceEpoch(utcEpoch, isUtc: true);
  debugPrint("UTC dt UTC $utcDtUtc");
now 2021-08-28 09:29:22.693
epoch 1630168162693
dt 2021-08-28 09:29:22.693
utcDt 2021-08-28 16:29:22.693Z
UTC Now 2021-08-28 16:29:22.693Z
UTC epoch 1630168162693
dt UTC 2021-08-28 09:29:22.693
UTC dt UTC 2021-08-28 16:29:22.693Z

@MrCsabaToth MrCsabaToth changed the title Adding time zone selection Adding time zone handling Aug 28, 2021
@MrCsabaToth
Copy link
Member Author

Took a look at https://pub.dev/packages/timezone but I decided to go with https://pub.dev/packages/flutter_native_timezone because it has a simple API which makes more sense.

@MrCsabaToth
Copy link
Member Author

https://pub.dev/packages/flutter_native_timezone shows empty string in debug. I may need to involve https://pub.dev/packages/timezone as well as a fallback?

@MrCsabaToth
Copy link
Member Author

It turns out that it was just a UI problem, the string is not empty it just needed it setState because it's async.

@MrCsabaToth
Copy link
Member Author

Now I need to address #139: per time zone based tracks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant