forked from SimformSolutionsPvtLtd/flutter_calendar_view
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support timezone and hour limitation
- Loading branch information
1 parent
79b9840
commit d39475f
Showing
9 changed files
with
152 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:timezone/standalone.dart' as tz; | ||
import 'package:timezone/timezone.dart'; | ||
|
||
class TimeZoneHelper { | ||
static DateTime? getTzDateFromDateTime( | ||
DateTime? dateTime, String locationName) { | ||
if (dateTime == null) { | ||
return null; | ||
} | ||
final Location location = tz.getLocation(locationName); | ||
return TZDateTime.from(dateTime, location); | ||
} | ||
|
||
static int getTimeZoneOffset(String location) { | ||
final now = DateTime.now(); | ||
return now.timeZoneOffset.inHours - | ||
getTzDateFromDateTime(now, location)!.timeZoneOffset.inHours; | ||
} | ||
|
||
static TimeOfDay addHour(TimeOfDay time, int hour) { | ||
return TimeOfDay(hour: time.hour + hour, minute: time.minute); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.