2023-01-02 22:40:53 +00:00
|
|
|
package funkin.util;
|
|
|
|
|
2023-11-07 09:04:22 +00:00
|
|
|
/**
|
|
|
|
* Utilities for performing operations on dates.
|
|
|
|
*/
|
2025-04-16 01:00:09 +00:00
|
|
|
@:nullSafety
|
2023-01-02 22:40:53 +00:00
|
|
|
class DateUtil
|
|
|
|
{
|
2025-04-16 01:00:09 +00:00
|
|
|
public static function generateTimestamp(?date:Date):String
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-08-22 08:27:30 +00:00
|
|
|
if (date == null) date = Date.now();
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
return
|
|
|
|
'${date.getFullYear()}-${Std.string(date.getMonth() + 1).lpad('0', 2)}-${Std.string(date.getDate()).lpad('0', 2)}-${Std.string(date.getHours()).lpad('0', 2)}-${Std.string(date.getMinutes()).lpad('0', 2)}-${Std.string(date.getSeconds()).lpad('0', 2)}';
|
|
|
|
}
|
2023-11-23 00:17:35 +00:00
|
|
|
|
2025-04-16 01:00:09 +00:00
|
|
|
public static function generateCleanTimestamp(?date:Date):String
|
2023-11-23 00:17:35 +00:00
|
|
|
{
|
|
|
|
if (date == null) date = Date.now();
|
|
|
|
|
|
|
|
return '${DateTools.format(date, '%B %d, %Y')} at ${DateTools.format(date, '%I:%M %p')}';
|
|
|
|
}
|
2023-01-02 22:40:53 +00:00
|
|
|
}
|