Need a formula: Extracting Years from Seconds Since January 1, 0001 12:00 AM

后端 未结 7 465
春和景丽
春和景丽 2021-01-12 05:22

Input: # of seconds since January 1st, of Year 0001

Output: # of Full years during this time period

I have developed an algorithm that I do not think is the

7条回答
  •  抹茶落季
    2021-01-12 05:53

    I think that this will work for you:

    function foo(days):
      count = days
      year = 0
      while (count > 0):
        if leap_year(year)
          count = count - 366
        else
          count = count - 365
        year ++
      return year
    

提交回复
热议问题