简体   繁体   English

UWP C#中的CalendarView显示错误的日期

[英]CalendarView in UWP C# showing wrong day

I have CalendarView on two pages. 我在两页上都有CalendarView。 First page is used to add records to calendar by assigning the selected date to the database record. 第一页用于通过将所选日期分配给数据库记录来将记录添加到日历。

Second page is used to show all records assigned to the selected date. 第二页用于显示分配给所选日期的所有记录。

Now, when on the first page I assign date to the product by clicking the date manually, on the second page product is shown correctly when selected date that corresponds to the products date. 现在,当我在第一页上通过手动单击日期为产品分配日期时,在第二页上,当所选日期对应于产品日期时,产品会正确显示。

However, when on the first page I add dates to the products programmatically, on the second page, these products are shown one day before than they should. 但是,当我在第一页上以编程方式向产品添加日期时,在第二页上,这些产品显示的日期比原应提前一天。

I have no idea what is happening. 我不知道发生了什么事。 I will post code if you want to check something. 如果您想检查一些东西,我会发布代码。

THe problem is strange, becaue on one calendar these automatically added dates are shown for example on 5th April, but on the second calendar they are listed under 4th April. 这个问题很奇怪,因为在一个日历上这些自动添加的日期显示在例如4月5日,但是在第二个日历上却在4月4日之下列出。

Is that the globalization of two calendars problem? 那是两个日历的全球化问题吗?

Locale(globalization ) would be a potential problem. 语言环境(全球化)将是一个潜在的问题。 But having code would help us to provide you more info. 但是拥有代码将帮助我们为您提供更多信息。

I have managed to resolve the problem. 我设法解决了这个问题。 It was in deed issue with DateTimeOffset/DateTime values. 确实存在DateTimeOffset / DateTime值的问题。

I changed every instance of Date I found in the code by appending it with 我在代码中找到的每个Date实例都附加了

.LocalDateTime .LocalDateTime

.

This way I got the correct local date of each DateTimeOffset object and data is added to/ pulled from the Calendar correctly. 这样,我得到了每个DateTimeOffset对象的正确本地日期,并且正确地将数据添加到了Calendar或从Calendar中提取了数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM