LCOV - code coverage report
Current view: top level - lib/_ext - date_time_ext.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 9 18 50.0 %
Date: 2024-10-04 11:12:13 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2023 The terCAD team. All rights reserved.
       2             : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3             : 
       4             : import 'package:app_finance/_classes/herald/app_locale.dart';
       5             : import 'package:intl/intl.dart';
       6             : 
       7             : extension DateTimeExt on DateTime {
       8           1 :   String yMEd() {
       9             :     DateFormat formatterDate;
      10             :     try {
      11           2 :       formatterDate = DateFormat.yMEd(AppLocale.code);
      12             :     } catch (e) {
      13           0 :       formatterDate = DateFormat.yMEd('en_US');
      14             :     }
      15           1 :     return formatterDate.format(this);
      16             :   }
      17             : 
      18           1 :   String yearMonth() {
      19             :     DateFormat formatterDate;
      20             :     try {
      21           2 :       formatterDate = DateFormat.yM(AppLocale.code);
      22             :     } catch (e) {
      23           0 :       formatterDate = DateFormat.yM('en_US');
      24             :     }
      25           1 :     return formatterDate.format(this);
      26             :   }
      27             : 
      28           1 :   String monthDay() {
      29             :     DateFormat formatterDate;
      30             :     try {
      31           2 :       formatterDate = DateFormat.MMMMd(AppLocale.code);
      32             :     } catch (e) {
      33           0 :       formatterDate = DateFormat.MMMMd('en_US');
      34             :     }
      35           1 :     return formatterDate.format(this);
      36             :   }
      37             : 
      38           0 :   String dateTime() {
      39             :     DateFormat formatterDate;
      40             :     DateFormat formatterTime;
      41             :     try {
      42           0 :       formatterDate = DateFormat.yMMMd(AppLocale.code);
      43           0 :       formatterTime = DateFormat.jms(AppLocale.code);
      44             :     } catch (e) {
      45           0 :       formatterDate = DateFormat.yMMMd('en_US');
      46           0 :       formatterTime = DateFormat.jms('en_US');
      47             :     }
      48           0 :     return '${formatterTime.format(this)}, ${formatterDate.format(this)}';
      49             :   }
      50             : }

Generated by: LCOV version 1.14