mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
331d37be7c
- **Settings:** - (Add) Remove source file after automatic conversion (#444) - (Add) Remove source file after manual conversion (#444) - (Add) **Average resin bottle cost:** The average cost per one resin bottle of 1000ml. Used to calculate the material cost when the file lacks that information. Use 0 to disable this feature and only show the cost if file have that information. If this value is changed, you need to reload the current file to update the cost. - (Change) Move "Expand and show tool descriptions by default" to From `General` to `Tools` tab (Setting will reset to default) - **File formats:** - (Add) Property `StartingMaterialMilliliters`: Gets the starting material milliliters when the file was loaded - (Add) Property `StartingMaterialCost`: Gets the starting material cost when the file was loaded - (Add) Property `MaterialMilliliterCost`: Gets the material cost per one milliliter - (Improvement) Update `MaterialCost` when `MaterialMilliliters` changes (#449) - **Raft relief:** - (Add) Linked lines: Remove the raft, keep supports and link them with lines - (Improvement) Change the supports detection parameters to be more effective and precise on detect the starting layer - (Fix) Brightness percentage not getting updated - (Fix) Remove anti-aliased edges from Tabs - (Improvement) Core: Minor clean-up - (Fix) Issue repair error when 'Auto repair layers and issues on file load' is enabled (#446) - (Fix) UI: Selecting a object with ROI when flip is verically, will cause 1px up-shift on the preview - (Fix) macOS permission error due loss of attributes on the build script, WSL have bug with mv, using ln&rm instead
82 lines
2.6 KiB
C#
82 lines
2.6 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
|
|
using System;
|
|
|
|
namespace UVtools.Core.Extensions;
|
|
|
|
public static class DateTimeExtensions
|
|
{
|
|
/// <summary>
|
|
/// Gets the Unix timestamp since Jan 1, 1970 UTC
|
|
/// </summary>
|
|
public static TimeSpan Timestamp => DateTime.UtcNow.Subtract(DateTime.UnixEpoch);
|
|
|
|
/// <summary>
|
|
/// Gets the Unix timestamp in seconds since Jan 1, 1970 UTC
|
|
/// </summary>
|
|
public static double TimestampSeconds => Timestamp.TotalSeconds;
|
|
|
|
/// <summary>
|
|
/// Gets the Unix minutes in seconds since Jan 1, 1970 UTC
|
|
/// </summary>
|
|
public static double TimestampMinutes => Timestamp.TotalMinutes;
|
|
|
|
/// <summary>
|
|
/// Gets the <see cref="DateTime"/> from a unix timestamp in seconds
|
|
/// </summary>
|
|
/// <param name="seconds"></param>
|
|
/// <returns></returns>
|
|
public static DateTime GetDateTimeFromTimestampSeconds(double seconds)
|
|
{
|
|
return DateTime.UnixEpoch.AddSeconds(seconds);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the <see cref="DateTime"/> from a unix timestamp in minutes
|
|
/// </summary>
|
|
/// <param name="minutes"></param>
|
|
/// <returns></returns>
|
|
public static DateTime GetDateTimeFromTimestampMinutes(double minutes)
|
|
{
|
|
return DateTime.UnixEpoch.AddMinutes(minutes);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Calculates the age in years of the current System.DateTime object today.
|
|
/// </summary>
|
|
/// <param name="birthDate">The date of birth</param>
|
|
/// <returns>Age in years today. 0 is returned for a future date of birth.</returns>
|
|
public static int Age(this DateTime birthDate)
|
|
{
|
|
return Age(birthDate, DateTime.Today);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Calculates the age in years of the current System.DateTime object on a later date.
|
|
/// </summary>
|
|
/// <param name="birthDate">The date of birth</param>
|
|
/// <param name="laterDate">The date on which to calculate the age.</param>
|
|
/// <returns>Age in years on a later day. 0 is returned as minimum.</returns>
|
|
public static int Age(this DateTime birthDate, DateTime laterDate)
|
|
{
|
|
var age = laterDate.Year - birthDate.Year;
|
|
|
|
if (age > 0)
|
|
{
|
|
age -= Convert.ToInt32(laterDate.Date < birthDate.Date.AddYears(age));
|
|
}
|
|
else
|
|
{
|
|
age = 0;
|
|
}
|
|
|
|
return age;
|
|
}
|
|
} |