Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/config_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class ConfigProvider with ChangeNotifier {
}

bool is24HourFormat() {
if (PlatformDispatcher.instance.alwaysUse24HourFormat) return true;
String formattedTime =
DateFormat.jm(PlatformDispatcher.instance.locale.toString())
.format(DateTime.now());
Expand Down
3 changes: 1 addition & 2 deletions lib/flashback_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:daily_you/l10n/generated/app_localizations.dart';
import 'package:daily_you/models/entry.dart';
import 'package:daily_you/models/flashback.dart';
import 'package:daily_you/time_manager.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';

class FlashbackManager {
Expand Down Expand Up @@ -136,7 +135,7 @@ class FlashbackManager {
entryLabels: entries.length == 1
? [label]
: entries
.map((e) => DateFormat.jm(locale).format(e.timeCreate))
.map((e) => TimeManager.localizedTimeFormat(locale).format(e.timeCreate))
.toList(),
));
});
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/edit_entry_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class _AddEditEntryPageState extends State<AddEditEntryPage>
VisualDensity.compact,
padding: EdgeInsets.all(6)),
child: Text(
DateFormat.jm(TimeManager
TimeManager.localizedTimeFormat(TimeManager
.currentLocale(
context))
.format(entryDate!),
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/entry_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class _EntryViewPageState extends State<EntryViewPage> {
radius: BorderRadius.circular(4),
),
Text(
DateFormat.jm(
TimeManager.localizedTimeFormat(
TimeManager.currentLocale(context))
.format(entry.timeCreate),
style: TextStyle(
Expand Down Expand Up @@ -141,7 +141,7 @@ class _EntryViewPageState extends State<EntryViewPage> {
padding: const EdgeInsets.only(
left: 8, top: 4, bottom: 18, right: 8),
child: Text(
"${AppLocalizations.of(context)!.lastModified}: ${DateFormat.yMMMEd(TimeManager.currentLocale(context)).format(entry.timeModified)} ${DateFormat.jm(TimeManager.currentLocale(context)).format(entry.timeModified)}",
"${AppLocalizations.of(context)!.lastModified}: ${DateFormat.yMMMEd(TimeManager.currentLocale(context)).format(entry.timeModified)} ${TimeManager.localizedTimeFormat(TimeManager.currentLocale(context)).format(entry.timeModified)}",
style: TextStyle(fontSize: 12, color: theme.disabledColor),
),
),
Expand Down
3 changes: 1 addition & 2 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:daily_you/pages/entries_list_page.dart';
import 'package:daily_you/pages/entry_timeline_page.dart';
import 'package:daily_you/pages/edit_entry_page.dart';
import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';

class HomePage extends StatefulWidget {
Expand Down Expand Up @@ -239,7 +238,7 @@ class _HomePageState extends State<HomePage>
.reversed
.toList(),
labelBuilder: (e) =>
DateFormat.jm(locale).format(e.timeCreate),
TimeManager.localizedTimeFormat(locale).format(e.timeCreate),
),
));
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/image_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class _ImageViewPageState extends State<ImageViewPage> {
const SizedBox(height: 8),
_infoRow(
Icons.schedule_rounded,
"${DateFormat.yMMMEd(TimeManager.currentLocale(context)).format(imageEntry.timeCreate)} ${DateFormat.jm(TimeManager.currentLocale(context)).format(imageEntry.timeCreate)}",
"${DateFormat.yMMMEd(TimeManager.currentLocale(context)).format(imageEntry.timeCreate)} ${TimeManager.localizedTimeFormat(TimeManager.currentLocale(context)).format(imageEntry.timeCreate)}",
),
],
),
Expand Down
3 changes: 2 additions & 1 deletion lib/template_renderer.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:daily_you/time_manager.dart';
import 'package:flutter/widgets.dart';
import 'package:intl/intl.dart';
import 'package:daily_you/l10n/generated/app_localizations.dart';
Expand Down Expand Up @@ -63,6 +64,6 @@ class TemplateRenderer {
// Do nothing
}

return DateFormat.jm(locale.toString()).format(dt);
return TimeManager.localizedTimeFormat(locale.toString()).format(dt);
}
}
11 changes: 10 additions & 1 deletion lib/time_manager.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:ui' show PlatformDispatcher;

import 'package:daily_you/config_provider.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
Expand Down Expand Up @@ -75,10 +77,17 @@ class TimeManager {
}

static String timeOfDayString(BuildContext context, TimeOfDay timeOfDay) {
return DateFormat.jm(TimeManager.currentLocale(context))
return localizedTimeFormat(TimeManager.currentLocale(context))
.format(addTimeOfDay(startOfDay(DateTime.now()), timeOfDay));
}

static DateFormat localizedTimeFormat(String locale) {
if (PlatformDispatcher.instance.alwaysUse24HourFormat) {
return DateFormat.Hm(locale);
}
return DateFormat.jm(locale);
}

static final Map<int, String> dayOfWeekIndexMapping = {
0: 'monday',
1: 'tuesday',
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/entry_day_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class EntryDayCell extends StatelessWidget {
.toList()
.reversed
.toList(),
labelBuilder: (e) => DateFormat.jm(locale).format(e.timeCreate),
labelBuilder: (e) => TimeManager.localizedTimeFormat(locale).format(e.timeCreate),
),
));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/vertical_calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class _VerticalCalendarState extends State<VerticalCalendar>
.toList()
.reversed
.toList(),
labelBuilder: (e) => DateFormat.jm(locale).format(e.timeCreate),
labelBuilder: (e) => TimeManager.localizedTimeFormat(locale).format(e.timeCreate),
),
));
}
Expand Down
Loading