Вы находитесь на странице: 1из 1

1. 11.3.1.

A Better Formula for Time Differences


Mt cng thc tt hn t!nh s" ch#nh l$ch th%i gian In Chapter 10, I told you that subtracting an earlier time from a later time is problematic if the earlier time is before midnight and the later time is after midnight. Heres the expression I showed you that overcomes this problem ! ch"#ng 10, t$i %& n'i v(i b)n vi*c l+y m,t th-i gian sau tr. %i m,t th-i gian tr"(c s/ g0y ra v+n %1 n2u nh" th-i gian tr"(c l3 tr"(c n4a %5m c6n th-i gian sau l3 n4a %5m. 70y l3 bi8u th9c m3 t$i %& tr:nh b3y v(i b)n %8 ;h<c ph=c v+n %1 n3y I>?@ndAime B CtartAime, 1 D @ndAime E CtartAime, @ndAime E CtartAimeF However, time values are seGuential and cyclical Aheyre real numbers that run from 0 to 1 and then start over at midnight. Aherefore, you can use HIJ?F to greatly simplify the formula for calculating the difference between two times Auy nhi5n, nhKng giL trM th-i gian th: c' tNnh tr:nh tO v3 tuPn ho3n ChQng l3 cLc sR thOc ch)y t. 0 %2n 1 v3 trS l)i t. %Pu lQc n4a %5m. Jo %', b)n c' th8 dTng h3m HIJ?F %8 %#n giUn %Lng ;8 c$ng th9c tNnh sO ch5nh l*ch giKa hai th-i gian V HIJ?@ndAime E CtartAime, 1F Ahis wor;s for any value of @ndAime and CtartAime, as long as @ndAime comes later than CtartAime. C$ng th9c n3y l3m vi*c v(i mWi giL trM cXa @ndAime v3 CtartAime, miYn l3 @ndAime %2n sau CtartAime

Вам также может понравиться