19 lines
779 B
Dart
19 lines
779 B
Dart
import 'package:intl/intl.dart';
|
||
import '../services/app_settings.dart';
|
||
|
||
/// Decimal number the way the language writes it: 8,49 (sl, de) or 8.49 (en).
|
||
String dec(double v, [int digits = 2]) {
|
||
final s = v.toStringAsFixed(digits);
|
||
return AppSettings.instance.language == 'English' ? s : s.replaceAll('.', ',');
|
||
}
|
||
|
||
/// Signed difference: "+0,21" / "−0,06".
|
||
String signedDec(double v, [int digits = 2]) => '${v >= 0 ? '+' : '−'}${dec(v.abs(), digits)}';
|
||
|
||
/// "čet, 12. 11." (or with the year): weekday without the locale's dot.
|
||
String dayDate(DateTime d, {bool year = false}) {
|
||
final s = AppSettings.instance;
|
||
final weekday = DateFormat('EEE', s.dateLocale).format(d).replaceAll('.', '');
|
||
return '$weekday, ${DateFormat(year ? 'd. M. yyyy' : 'd. M.').format(d)}';
|
||
}
|