Vaibhav Surve 99902e743c Flutter application
- Created generated_plugin_registrant.cc and generated_plugin_registrant.h to manage plugin registration.
- Added generated_plugins.cmake for plugin configuration in CMake.
- Implemented CMakeLists.txt for the Windows runner, defining build settings and dependencies.
- Created Runner.rc for application resources including versioning and icons.
- Developed flutter_window.cpp and flutter_window.h to manage the Flutter window lifecycle.
- Implemented main.cpp as the entry point for the Windows application.
- Added resource.h for resource definitions.
- Included app icon in resources.
- Created runner.exe.manifest for application settings.
- Developed utils.cpp and utils.h for console management and command line argument handling.
- Implemented win32_window.cpp and win32_window.h for high DPI-aware window management.
2025-04-17 12:30:38 +05:30

80 lines
2.3 KiB
Dart

import 'package:marco/helpers/extensions/date_time_extension.dart';
class Utils {
static getDateStringFromDateTime(DateTime dateTime,
{bool showMonthShort = false}) {
String date =
dateTime.day < 10 ? "0${dateTime.day}" : dateTime.day.toString();
late String month;
if (showMonthShort) {
month = dateTime.getMonthName();
} else {
month = dateTime.month < 10
? "0${dateTime.month}"
: dateTime.month.toString();
}
String year = dateTime.year.toString();
String separator = showMonthShort ? " " : "/";
return "$date$separator$month$separator$year";
}
static getTimeStringFromDateTime(
DateTime dateTime, {
bool showSecond = true,
}) {
String hour = dateTime.hour.toString();
if (dateTime.hour > 12) {
hour = (dateTime.hour - 12).toString();
}
String minute = dateTime.minute < 10
? "0${dateTime.minute}"
: dateTime.minute.toString();
String second = "";
if (showSecond) {
second = dateTime.second < 10
? "0${dateTime.second}"
: dateTime.second.toString();
}
String meridian = "";
meridian = dateTime.hour < 12 ? " AM" : " PM";
return "$hour:$minute${showSecond ? ":" : ""}$second$meridian";
}
static String getDateTimeStringFromDateTime(DateTime dateTime,
{bool showSecond = true,
bool showDate = true,
bool showTime = true,
bool showMonthShort = false}) {
if (showDate && !showTime) {
return getDateStringFromDateTime(dateTime);
} else if (!showDate && showTime) {
return getTimeStringFromDateTime(dateTime, showSecond: showSecond);
}
return "${getDateStringFromDateTime(dateTime, showMonthShort: showMonthShort)} ${getTimeStringFromDateTime(dateTime, showSecond: showSecond)}";
}
static String getStorageStringFromByte(int bytes) {
double b = bytes.toDouble(); //1024
double k = bytes / 1024; //1
double m = k / 1024; //0.001
double g = m / 1024; //...
double t = g / 1024; //...
if (t >= 1) {
return "${t.toStringAsFixed(2)} TB";
} else if (g >= 1) {
return "${g.toStringAsFixed(2)} GB";
} else if (m >= 1) {
return "${m.toStringAsFixed(2)} MB";
} else if (k >= 1) {
return "${k.toStringAsFixed(2)} KB";
} else {
return "${b.toStringAsFixed(2)} Bytes";
}
}
}