Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dateTimeFormatter to support non-standard calendars #15

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 1 addition & 22 deletions src/NodeTools.cs
Expand Up @@ -165,28 +165,7 @@ internal static class NodeTools {
}

internal static string ConvertUTtoHumanTime (double UT, bool compact = false) {
long secs;
long mins;
long hour;
long day;
long year;

if (GameSettings.KERBIN_TIME) {
secs = (long)Math.Floor (UT % 60);
mins = (long)Math.Floor ((UT / 60) % 60);
hour = (long)Math.Floor ((UT / (60 * 60)) % 6);
day = (long)Math.Floor ((UT / (6 * 60 * 60)) % 426) + 1; // Ensure we don't get a "Day 0" here.
year = (long)Math.Floor (UT / (426 * 6 * 60 * 60)) + 1; // Ensure we don't get a "Year 0" here.
} else {
secs = (long)Math.Floor (UT % 60);
mins = (long)Math.Floor ((UT / 60) % 60);
hour = (long)Math.Floor ((UT / (60 * 60)) % 24);
day = (long)Math.Floor ((UT / (24 * 60 * 60)) % 365) + 1; // Ensure we don't get a "Day 0" here.
year = (long)Math.Floor (UT / (365 * 24 * 60 * 60)) + 1; // Ensure we don't get a "Year 0" here.
}

string format = compact ? "precisemaneuver_date_format_compact" : "precisemaneuver_date_format";
return Localizer.Format (format, year, day, hour, mins.ToString ("D2"), secs.ToString ("D2"));
return compact ? KSPUtil.dateTimeFormatter.PrintDateCompact(UT, true, true) : KSPUtil.dateTimeFormatter.PrintDate(UT, true, true);
}

internal static void CopyToClipboard (Orbit o, ManeuverNode node) {
Expand Down