mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00

This is super ugly, but it solves a real use case, and hopefully I'll eventually get around to improving the UI of the Settings page.
30 lines
661 B
Dart
30 lines
661 B
Dart
import 'package:intl/intl.dart';
|
|
|
|
String toIso8601(DateTime dt) {
|
|
return DateFormat("yyyy-MM-ddTHH:mm:ss").format(dt);
|
|
}
|
|
|
|
String toIso8601WithTimezone(DateTime dt) {
|
|
var result = DateFormat("yyyy-MM-ddTHH:mm:ss").format(dt);
|
|
|
|
var offset = dt.timeZoneOffset;
|
|
int minutes = (offset.inMinutes % 60);
|
|
int hours = offset.inHours.toInt();
|
|
|
|
String minutesStr;
|
|
if (minutes < 10) {
|
|
minutesStr = '0' + minutes.toString();
|
|
} else {
|
|
minutesStr = minutes.toString();
|
|
}
|
|
|
|
String hourStr;
|
|
if (hours < 10) {
|
|
hourStr = '0' + hours.toString();
|
|
} else {
|
|
hourStr = hours.toString();
|
|
}
|
|
|
|
return result + '+' + hourStr + ':' + minutesStr;
|
|
}
|