converting and desconverting all dates to utc
This commit is contained in:
@@ -65,7 +65,7 @@ class ClockInRepositoryImpl implements ClockInRepositoryInterface {
|
||||
/// Helper to create Timestamp from DateTime
|
||||
Timestamp _fromDateTime(DateTime d) {
|
||||
// Assuming Timestamp.fromJson takes an ISO string
|
||||
return Timestamp.fromJson(d.toIso8601String());
|
||||
return Timestamp.fromJson(d.toUtc().toIso8601String());
|
||||
}
|
||||
|
||||
/// Helper to find today's active application
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:firebase_data_connect/firebase_data_connect.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
import 'package:krow_domain/krow_domain.dart' as domain;
|
||||
import 'package:krow_core/core.dart';
|
||||
|
||||
import '../../domain/repositories/certificates_repository.dart';
|
||||
|
||||
@@ -63,7 +64,9 @@ class CertificatesRepositoryImpl implements CertificatesRepository {
|
||||
description: null, // Description not available in this query response
|
||||
status: _mapStatus(doc.status),
|
||||
documentUrl: doc.documentUrl,
|
||||
expiryDate: doc.expiryDate?.toDateTime(),
|
||||
expiryDate: doc.expiryDate == null
|
||||
? null
|
||||
: DateTimeUtils.toDeviceTime(doc.expiryDate!.toDateTime()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:firebase_data_connect/firebase_data_connect.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
import 'package:krow_domain/krow_domain.dart' as domain;
|
||||
import 'package:krow_core/core.dart';
|
||||
|
||||
import '../../domain/repositories/documents_repository.dart';
|
||||
|
||||
@@ -75,7 +76,9 @@ class DocumentsRepositoryImpl implements DocumentsRepository {
|
||||
description: null, // Description not available in data source
|
||||
status: _mapStatus(doc.status),
|
||||
documentUrl: doc.documentUrl,
|
||||
expiryDate: doc.expiryDate?.toDateTime(),
|
||||
expiryDate: doc.expiryDate == null
|
||||
? null
|
||||
: DateTimeUtils.toDeviceTime(doc.expiryDate!.toDateTime()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:firebase_data_connect/firebase_data_connect.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart' as dc;
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
|
||||
@@ -62,14 +63,17 @@ class TaxFormMapper {
|
||||
status: form.status.stringValue,
|
||||
staffId: form.staffId,
|
||||
formData: formData,
|
||||
updatedAt: form.updatedAt?.toDateTime(),
|
||||
updatedAt: form.updatedAt == null
|
||||
? null
|
||||
: DateTimeUtils.toDeviceTime(form.updatedAt!.toDateTime()),
|
||||
);
|
||||
}
|
||||
|
||||
static String? _formatDate(Timestamp? timestamp) {
|
||||
if (timestamp == null) return null;
|
||||
|
||||
final DateTime date = timestamp.toDateTime();
|
||||
final DateTime date =
|
||||
DateTimeUtils.toDeviceTime(timestamp.toDateTime());
|
||||
|
||||
return '${date.month.toString().padLeft(2, '0')}/${date.day.toString().padLeft(2, '0')}/${date.year}';
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:krow_data_connect/krow_data_connect.dart' as dc;
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:krow_domain/src/adapters/financial/time_card_adapter.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import '../../domain/repositories/time_card_repository.dart';
|
||||
|
||||
/// Implementation of [TimeCardRepository] using Firebase Data Connect.
|
||||
@@ -40,12 +41,15 @@ class TimeCardRepositoryImpl implements TimeCardRepository {
|
||||
|
||||
return result.data.applications
|
||||
.where((dc.GetApplicationsByStaffIdApplications app) {
|
||||
final DateTime? shiftDate = app.shift.date?.toDateTime();
|
||||
final DateTime? shiftDate = app.shift.date == null
|
||||
? null
|
||||
: DateTimeUtils.toDeviceTime(app.shift.date!.toDateTime());
|
||||
if (shiftDate == null) return false;
|
||||
return shiftDate.year == month.year && shiftDate.month == month.month;
|
||||
})
|
||||
.map((dc.GetApplicationsByStaffIdApplications app) {
|
||||
final DateTime shiftDate = app.shift.date!.toDateTime();
|
||||
final DateTime shiftDate =
|
||||
DateTimeUtils.toDeviceTime(app.shift.date!.toDateTime());
|
||||
final String startTime = _formatTime(app.checkInTime) ?? _formatTime(app.shift.startTime) ?? '';
|
||||
final String endTime = _formatTime(app.checkOutTime) ?? _formatTime(app.shift.endTime) ?? '';
|
||||
|
||||
@@ -73,6 +77,7 @@ class TimeCardRepositoryImpl implements TimeCardRepository {
|
||||
|
||||
String? _formatTime(fdc.Timestamp? timestamp) {
|
||||
if (timestamp == null) return null;
|
||||
return DateFormat('HH:mm').format(timestamp.toDateTime());
|
||||
return DateFormat('HH:mm')
|
||||
.format(DateTimeUtils.toDeviceTime(timestamp.toDateTime()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user