year seleciton, day, hour
This commit is contained in:
parent
a0504e74e9
commit
ce7159c17a
2 changed files with 33 additions and 10 deletions
12
src/Main.cs
12
src/Main.cs
|
|
@ -149,7 +149,7 @@ public partial class Main : Control
|
|||
{
|
||||
double hours = GetLocalTime(GetNode<Node3D>("%Pointer").GlobalPosition, GetNode<Node3D>("%Sun").GlobalTransform.Basis.Z,
|
||||
_meshInstance);
|
||||
GetNode<Label>("%LocalTime").Text = DaysToTime(_sunRotation * 365.0, hours);
|
||||
GetNode<Label>("%LocalTime").Text = DaysToDate(_sunRotation * 365.0, hours);
|
||||
|
||||
GetNode<Label>("%Date").Text = DaysToDate(_sunRotation * 365.0, _planetRotation*24.0);
|
||||
}
|
||||
|
|
@ -177,18 +177,24 @@ public partial class Main : Control
|
|||
|
||||
public string DaysToDate(double days, double hours)
|
||||
{
|
||||
DateTime dt = new DateTime(1, 1, 1);
|
||||
DateTime dt = new DateTime(int.Parse(GetNode<LineEdit>("%Year").Text), 1, 1);
|
||||
dt = dt.AddDays(days);
|
||||
dt = dt.AddHours(hours);
|
||||
return dt.ToString("'y'yyyy/'m'MM/'d'dd - 'h'HH':''m'mm':''s'ss");
|
||||
}
|
||||
public string DaysToTime(double days, double hours)
|
||||
{
|
||||
DateTime dt = new DateTime(1, 1, 1);
|
||||
DateTime dt = new DateTime(int.Parse(GetNode<LineEdit>("%Year").Text), 1, 1);
|
||||
dt = dt.AddDays(days);
|
||||
dt = dt.AddHours(hours);
|
||||
return dt.ToString("'h'HH':''m'mm':''s'ss");
|
||||
}
|
||||
|
||||
public void YearChanged(string year)
|
||||
{
|
||||
if (int.TryParse(year, out _))
|
||||
UpdateTime();
|
||||
}
|
||||
public void UpdateStats()
|
||||
{
|
||||
if (_vertex != null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue