如何编程数学以在日历中查找日期? [英] How do I program the math to find a date in a made up calendar?

查看:77
本文介绍了如何编程数学以在日历中查找日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想创建一个更大的程序,我使用基于组合日历创建的日历控件。日期和月份的设置与现在或过去在地球上使用的设置不同。我需要的是找到一种方法来建立基于所选月,周,年设置的控件。



我想我问这个错了。如何计算可以更改周长,月长和年长设置的日历的月视图。 \



* EDIT2:

我正在寻找问题的数学部分。我可以弄清楚如何查看视图部分,如果我能弄清楚如何弄清楚每个日期在哪一天下降。如果每年有16个月,有8周的周,以及23到34天的月份,我怎么知道9/4/129(月/日/年)的哪一天。



END EDIT2 *



*编辑:

我希望用户能够选择:



  • 一年中有多少个月
  • 每个月的天数
  • 一周中的天数
  • So I want to create a much bigger program where I use a calendar control that is created based on a made up calendar. The setup of the days and months are different from the ones that are used on earth now or in the past. What I need is to find a way to build the control based on the chosen month, week, year setup.

    I guess I am asking this wrong. How do I calculate a month view for a calendar where the setup of the week length, month length, and year length, can be changed. \

    *
    I am looking for the math portion of the problem. I can figure out how to do the view portion if I can figure out how to figure out on what day each date falls programicly. If each year has 16 months, with weeks 8 days long, and months ranging from 23 to 34 days long how do I find out what day 9/4/129 (d/m/y) is on.

    END EDIT2 *

    *
    I want the user to be able to choose:


    • how many months are in a year
    • how many days are in each month
    • how many days are in a week
    • 推荐答案

      你需要一个日历的开始日期,日历的第一个工作日,如何计算闰日的策略(一般来说,闰日不一定需要在一个月末,并且可能有一个以上的闰日(IIRC) ,一些古老的日历甚至有闰月))。

      例如格里高利历从1582年10月15日星期五开始。

      一般来说,这种通用日历没有封闭的数学公式。

      你只需要开始计算从日历开始的年份长度(包括所需的闰日),并确定该特定年份的第一天的工作日。然后你计算那一年的月份和闰日到期望的日期,同时跟踪工作日。

      干杯

      Andi
      You need a start date of the calendar, a first weekday of the calendar, a strategy how to calculate the leap days (in general, leap days do not necessarily need to be at the end of a month and there may be more than one leap day (IIRC, some ancient calendars even had leap months)).
      E.g. the Gregorian calendar started on Friday October 15, 1582.
      In general, there is no closed math formula for such a generic calendar.
      You simply start counting year lengths (including the needed leap days) from the beginning of the calendar and determine the weekday of the first day of that particular year. Then you count up for that year through the months and the leap days to the desired date while keeping track of the weekday.
      Cheers
      Andi

      这篇关于如何编程数学以在日历中查找日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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