zoukankan      html  css  js  c++  java
  • Get the Degree of Angle Between Hour and Minute Hand of a Clock at Anytime

    We need to calculate Degree of angle between hour and minute hand Sometimes.

    So I wrote a function to solve it:

     

    1. Function Hourhandminute(ByVal mytime As DateAs String
    2. Dim t As Single, h As Long, m As Long, s As Long
    3. h = Hour(mytime)
    4. m = Minute(mytime)
    5. s = Second(mytime)
    6. If h > 11 Then h = h - 12
    7. t = Abs(11 * m / 2 - 30 * h+11 * s / 120)
    8. If t > 180 Then t = 360 - t
    9. Hourhandminute = Abs(t)
    10. End Function

    Errors may be occured because of the calculating precision. But in most occasions,the results were right.

    For example:

    1. Sub Getall()
    2. Dim i As Single
    3. For i = 0 To 1 Step 1 / 86400
    4. If Abs(Hourhandminute(i) - 180) < 0.09 Then Debug.Print Format(i, "hh:mm:ss")
    5. Next
    6. End Sub

    It will return the time when the degree of angle between hour and minute hand is 180°

    00:32:43
    01:38:10
    02:43:38
    03:49:05
    04:54:32
    06:00:00
    07:05:28
    08:10:55
    09:16:22
    10:21:50
    11:27:17
    12:32:43
    13:38:10
    14:43:38
    15:49:05
    16:54:32
    18:00:00
    19:05:28
    20:10:55
    21:16:22
    22:21:50
    23:27:17

  • 相关阅读:
    Angular
    Angular
    Angular
    Angular
    Angular
    Angular
    Angular
    springsecurity 源码解读 之 RememberMeAuthenticationFilter
    springsecurity 源码解读之 AnonymousAuthenticationFilter
    springsecurity 源码解读之 SecurityContext
  • 原文地址:https://www.cnblogs.com/fengju/p/6336239.html
Copyright © 2011-2022 走看看