From f8ed0384dd5eb13935f3111ff7e4805a3d21f88b Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 2 Oct 2019 12:40:16 +0000 Subject: [PATCH] [Intl] Remove dependency --- lib/src/utils/ChatTime.dart | 14 ++++++-------- pubspec.lock | 7 ------- pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/lib/src/utils/ChatTime.dart b/lib/src/utils/ChatTime.dart index f53c058..e8a0f99 100644 --- a/lib/src/utils/ChatTime.dart +++ b/lib/src/utils/ChatTime.dart @@ -21,10 +21,6 @@ * along with famedlysdk. If not, see . */ -// TODO: localize this! - -import 'package:intl/intl.dart'; - /// Used to localize and present time in a chat application manner. class ChatTime { DateTime dateTime = DateTime.now(); @@ -75,9 +71,9 @@ class ChatTime { return "Sonntag"; } } else if (sameYear) { - return DateFormat('dd.MM').format(dateTime); + return "${_z(dateTime.day)}.${_z(dateTime.month)}"; } - return DateFormat('dd.MM.yyyy').format(dateTime); + return "${_z(dateTime.day)}.${_z(dateTime.month)}.${_z(dateTime.year)}"; } /// Returns the milliseconds since the Unix epoch. @@ -122,7 +118,7 @@ class ChatTime { /// Returns a simple time String. String toTimeString() { - return DateFormat('HH:mm').format(dateTime); + return "${_z(dateTime.hour)}.${_z(dateTime.minute)}"; } /// If the ChatTime is today, this returns [toTimeString()], if not it also @@ -136,6 +132,8 @@ class ChatTime { sameYear && now.month == dateTime.month && now.day == dateTime.day; if (sameDay) return toTimeString(); - return "${toString()}, ${DateFormat('HH:mm').format(dateTime)}"; + return "${toString()}, ${toTimeString()}"; } + + static String _z(int i) => i < 10 ? "0${i.toString()}" : i.toString(); } diff --git a/pubspec.lock b/pubspec.lock index a56a7af..2db5376 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -214,13 +214,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.4" - intl: - dependency: "direct main" - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.0" io: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index ed1aa2c..0b86e36 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: http: ^0.12.0+2 mime_type: ^0.2.4 - intl: ^0.16.0 + #intl: ^0.16.0 json_annotation: ^2.4.0