时间跨度和日期时间计算 [英] Time Span and Date Time Computation

查看:242
本文介绍了时间跨度和日期时间计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个问题,也许经验丰富的程序员可以为我提供帮助.
示例:如果一列火车在下午4:00离开纽约,并在晚上11时到达芝加哥,则行程多长时间.
(容易的部分)但是关键在于:晚上有几个小时和几分钟,白天有几个小时和分钟.您需要考虑它所跨越的时区以及每个城市的官方日落和日出.
他是我要完成的目标的要旨.我有一个asp.net函数,可以告诉我每个城市处于哪个时区,以及每个城市那天的太阳何时升起和落下.现在我要完成的就是这个.我正在尝试开发一个函数,该函数可以告诉我白天在小时和分钟内在火车上停留了多少时间,而后又告诉我晚上在火车上停留了多少时间.有人有想法么???有没有人听说过任何可以完成此功能的功能或JavaScript ??
提前谢谢.

Hello Everyone,
I have a question that maybe an experienced programmer can help me with.
Example: If a train left NY at 4:00PM and Arrived in Chicago at 11PM How long was the trip.
(Easy part) But here the clincher: and how many hours and minutes were at night and how many hours and minutes were during the day. You will need to take into consideration the time zones it crosses and the official sunset and sunrise for each city.
He is the gist of what I am trying to accomplish. I have a asp.net function that can tell me what time-zone each city is in and when the sun rise and sets for that day for each city. Now what I am trying to accomplish is this. I am trying to develop a function that will tell me how much time I was on the train during the day hours and minutes and then how much time I was on the train at night. Anyone have any ideas??? Has anyone heard of any function or javascript out there that would accomplish this???
Thanks In advance.

推荐答案

哦,太好了.
这不是关于编程,而是关于基础数学(嗯,非常基础).

这个问题是不恰当的. 您无法计算此时间,因为未提供路线和时间表.换句话说,您需要时空火车的详细轨迹(称为世界线")以及空间中每个点(而不仅仅是每个城市)的有关日落/日出的信息.同样,严格来说,这取决于您如何定义日落/日出:它可以是轨迹点的本地时间,也可以是时区的官方值,这略有不同.另外,您应该考虑到,随着火车的驶入,日落/日出会发生变化.

我可以解释为什么没有这些附加信息就无法解决此问题.

为了说明这一点,让我们考虑两个不同的时间表.考虑火车直线行驶.在一种情况下,火车以非常低的速度正好移动一半,其余部分则以快速速度移动.第二种情况恰恰相反:快然后慢,整个行程要花相同的时间.当火车从东向西移动并在日落之前离开时,它会在某个时间点遇见日落,这在第二种情况下会更快发生.在2D图片上绘制三条世界线(横坐标:时间,纵坐标:经度,两条线用于两个火车时刻表,第三条线用于日落点),显示火车线与日落线的交点,您将看到它. >
现在,请不要告诉我这是火车沿直线轨迹或其他假设以恒定速度行驶. 1)在现实生活中并非如此; 2)即使您想解决非常理想的问题,也不会假设任何理想化,但应精确指定.

问题最终确定:没有明确的解决方案.
Oh, great.
This is not about programming but about elementary mathematics (well, very elementary).

This problem is ill-posed. You cannot calculate this time, because the route and schedule is not provided. In other words, you need a detailed trajectory of the train in the space-time (called World line) and information about sunset/sunrise for every point in space (not just for each city). Also, this, strictly speaking, depends on how you define sunset/sunrise: it can be a local time in trajectory point or official value for the time zone, which is slightly different. Also, you should take into account, that sunset/sunrise changes as the train goes.

I can explain why you cannot solve this problem without this additional information.

To illustrate this, let''s consider two different schedules. Consider the train move in a straight line. In one case, train moves exactly half of the way at very slow speed, the rest of the way at fast speed. In second case is just the opposite: fast, then slow, to take the same time for the whole travel. As the train moves East to West and departs before sunset, it meets sunset at some point which happens sooner for second case. Draw three World lines on a 2D picture (abscissa: time, ordinate: longitude, two lines for two train schedules and third line for sunset points), show intersections of the train lines with the sunset line and you will see it.

Please don''t tell me now it is that the train moves at constant speed along straight trajectory or other assumptions. 1) In real life this is not the case; 2) even if you want to solve very idealized problem, none of the idealization are assumed, but should be specified precisely.

The problem is finalized: there is no unambiguous solution.


这篇关于时间跨度和日期时间计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆