Skip to content

Commit 4265103

Browse files
committed
feat(Util): Add time format full
1 parent 2ee8156 commit 4265103

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

Assets/JCSUnity/Scripts/Util/JCS_Time.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace JCSUnity
1414
/// <summary>
1515
/// Provides an interface to get time information from Unity.
1616
/// </summary>
17-
public static class JCS_Time
17+
public static class JCS_Time
1818
{
1919
/* Variables */
2020

@@ -23,8 +23,9 @@ public static class JCS_Time
2323
/* Functions */
2424

2525
/// <summary>
26-
/// Get the time by type.
26+
/// Return the time by type.
2727
/// </summary>
28+
/// <param name="type"> The type of the time you want to get. </param>
2829
public static float ItTime(JCS_TimeType type)
2930
{
3031
switch (type)
@@ -51,16 +52,17 @@ public static float ItTime(JCS_TimeType type)
5152
}
5253

5354
/// <summary>
54-
/// Return the time similar to skill time.
55+
/// Return the time largest unit time.
5556
///
5657
/// - For day: 1d
5758
/// - For hour: 2h
5859
/// - For minute: 3m
5960
/// - For second: 4s
6061
/// </summary>
61-
public static string Format(float seconds)
62+
/// <param name="val"> Time value. </param>
63+
public static string FormatLargest(double val)
6264
{
63-
TimeSpan time = TimeSpan.FromSeconds(seconds);
65+
TimeSpan time = TimeSpan.FromSeconds(val);
6466

6567
if (time.Days > 0)
6668
return $"{time.Days}d";
@@ -73,5 +75,15 @@ public static string Format(float seconds)
7375

7476
return "";
7577
}
78+
79+
/// <summary>
80+
/// Return the time string in full colon format.
81+
/// </summary>
82+
/// <param name="val"> Time value. </param>
83+
public static string FormatFull(double val)
84+
{
85+
TimeSpan ts = TimeSpan.FromSeconds(val);
86+
return ts.ToString(@"hh\:mm\:ss");
87+
}
7688
}
7789
}

0 commit comments

Comments
 (0)