有天工作不夜在NodaTime启动

编程入门 行业动态 更新时间:2024-10-13 12:24:32
本文介绍了有天工作不夜在NodaTime启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的工作有列车时刻表,其中第一个火车是0400,而末班车时间在0200这个应用程序的用户,因此应对启动0300天,在0300结束。换句话说,当一个应用程序他们说:周三的火车0200,他们真的是留下周四0200火车。

I am working on an application with train schedules, where the first train leaves at 0400 while the last train leaves at 0200. The users of this application therefore deal with days starting at 0300 and ending at 0300. In other words, when they say "The Wednesday-train at 0200" they really mean "The train that leaves on Thursday at 0200".

我们的应用程序需要存储所有列车离开上(例如)周三,这意味着它不应包含0300之前离开列车,但它应该包括火车那第二天离开的,直到0300

Our application needs to store all of the trains leaving on (for example) Wednesday, which means it should not include the trains that leave before 0300 but it should include the trains that leave the next day until 0300.

我将如何代表这在应用程序,而要疯了?而如何把这个存储在方便查询数据库?

How would I represent this in application without going mad? And how should this be stored in a database for easy querying?

推荐答案

我将存储的实际日期/时间值。然后进行查询,搜索什么周三你会从0400周三(含)到周四0400(不含)。

I would store the actual date/time value. Then for querying, to search for "anything on Wednesday" you'd go from Wednesday 0400 (inclusive) to Thursday 0400 (exclusive).

在显示方面,你倒是可能是最好服用日期,并减去一天,如果时间超过一定截止前面:

In terms of display, you'd probably be best taking the date, and subtracting a day if the time is earlier than some cutoff:

private static readonly LocalTime CutOff = new LocalTime(4, 0, 0); ... LocalDate date = dateTime.Date; if (dateTime.TimeOfDay < CutOff) { date = date.PlusDays(-1); } var dayOfWeek = date.IsoDayOfWeek;

我会尽量避免使用它自己的日期尽量避免去疯了。任何日期/时间将是明确的。

I would try to avoid using the date on its own as far as possible, to avoid going mad. Any date/time will be unambiguous.

更多推荐

有天工作不夜在NodaTime启动

本文发布于:2023-11-28 13:40:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642633.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:天工   作不夜   NodaTime

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!