private static void CalculateLevels() { DateTime lastDate = DateTime.Now; int lastGas = 0, lastLow = 0, lastHigh = 0; foreach (var record in Records) { DateTimeWeekNumber dwn = new DateTimeWeekNumber(record.Date); record.Week = dwn.ISOWeekNoExtended; if (lastGas != 0) { record.Time = record.Date - lastDate; record.Gas = record.LevelGas - lastGas; record.Low = record.LevelLow - lastLow; record.High = record.LevelHigh - lastHigh; if (record.Gas < 0) { record.Gas = record.LevelGas; record.Low = record.LevelLow; record.High = record.LevelHigh; } } record.Current = record.Low + record.High; lastDate = record.Date; lastGas = record.LevelGas; lastLow = record.LevelLow; lastHigh = record.LevelHigh; } }
private void GetWeekNumber() { DateTimeWeekNumber dwn = new DateTimeWeekNumber(Date.SelectedDate.Value); WeekNumber.Text = dwn.WeekNoCompact; //19041 Reference.Text = $"{WeekNumber.Text}00"; //1904100 }
private void ProjectDate_SelectedDateChanged() { DateTimeWeekNumber dwn = new DateTimeWeekNumber(DatePickerProjectDate.SelectedDate.Value); SelectedWeekNoCompact = dwn.WeekNoCompact; SelectedWeekNoMaxumumCount = GetSelectedWeekNoMaxumumCount(SelectedWeekNoCompact); CurrentWeekNoCompact.Text = $"WeekRef: {SelectedWeekNoCompact}"; CurrentWeekNoCount.Text = $"Max: {SelectedWeekNoMaxumumCount}"; }
private void GetDate() { DateTime?date = DateTimeWeekNumber.WeekNoCompactToDate(InputReference.Text); if (date == null) { ReferenceDate.Text = "Invalidate"; } else { ReferenceDate.Text = date.Value.ToString("yyyy-MM-dd"); } }
public ProjectWindow(Project projectParameter, ProjectWindowsArgs e) { projectScreen = projectParameter.Copy(); windowsArgs = e; e.Save = false; e.ProjectScreen = projectScreen; DataContext = projectScreen; InitializeComponent(); Title.Text += $" {DateTimeWeekNumber.WeekNoCompactToDate(projectScreen.WeekNoCompact).Value.ToString("yyyy-MM-dd")}"; ButtonSave.IsEnabled = !string.IsNullOrWhiteSpace(ProjectName.Text); ProjectName.Focus(); }
static void Main(string[] args) { Console.WriteLine($"Today: {DateTime.Now.ToString("yyyy-MM-dd")}"); string Reference = "1903401"; Console.Write($"Reference {Reference} => "); DateTime?date = DateTimeWeekNumber.WeekNoCompactToDate(Reference); if (date == null) { Console.WriteLine("Is invalid"); } else { Console.WriteLine(date); } Console.Write("\nPress any key..."); Console.ReadKey(); }