using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using AsbCloudDb.Model; using AsbCloudDb; using Google.Apis.Drive.v3.Data; using Microsoft.EntityFrameworkCore; namespace ConsoleApp1 { //var options = new DbContextOptionsBuilder() // .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") // .Options; //var context = new AsbCloudDbContext(options); class Program { private static double AssumeTimezoneOffset(DateTime nearToCurrentDate) { var offset = 5d; if (nearToCurrentDate.Kind == DateTimeKind.Unspecified) { var now = DateTime.UtcNow; var minutes = 60 * (now.Hour - nearToCurrentDate.Hour) + now.Minute - nearToCurrentDate.Minute; var minutesPositive = (1440_0000 + minutes) % 1440; //60*24 var halfsHours = Math.Round(1d * minutesPositive / 30d); // quarters are ignored var hours = halfsHours / 2; offset = hours < 12 ? hours : 24 - hours ; } if (nearToCurrentDate.Kind == DateTimeKind.Local) offset = TimeZoneInfo.Local.BaseUtcOffset.TotalHours; return offset; } static void Main(/*string[] args*/) { var o = AssumeTimezoneOffset(new DateTime(2022, 01, 10, 15, 40, 00)); //DbDemoDataService.AddDemoData(); //.GetAwaiter().GetResult(); Console.WriteLine("End of Test"); Console.ReadLine(); //var options = new DbContextOptionsBuilder() // .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") // .Options; //var context = new AsbCloudDbContext(options); //var sett = context.Set(); //var r = context.Database.ExecInsertOrUpdateAsync(sett, new List { // new TelemetryDataSaub // { // Date = DateTime.Now, // IdTelemetry = 3, // AxialLoad = 100.1f, // }, // new TelemetryDataSaub // { // Date = DateTime.Now.AddSeconds(2), // IdTelemetry = 3, // AxialLoad = 100.2f, // }, //}, System.Threading.CancellationToken.None).Result; } } }