1. <small id='SQZRL'></small><noframes id='SQZRL'>

  2. <legend id='SQZRL'><style id='SQZRL'><dir id='SQZRL'><q id='SQZRL'></q></dir></style></legend>

        <bdo id='SQZRL'></bdo><ul id='SQZRL'></ul>

      <i id='SQZRL'><tr id='SQZRL'><dt id='SQZRL'><q id='SQZRL'><span id='SQZRL'><b id='SQZRL'><form id='SQZRL'><ins id='SQZRL'></ins><ul id='SQZRL'></ul><sub id='SQZRL'></sub></form><legend id='SQZRL'></legend><bdo id='SQZRL'><pre id='SQZRL'><center id='SQZRL'></center></pre></bdo></b><th id='SQZRL'></th></span></q></dt></tr></i><div id='SQZRL'><tfoot id='SQZRL'></tfoot><dl id='SQZRL'><fieldset id='SQZRL'></fieldset></dl></div>
      <tfoot id='SQZRL'></tfoot>

      按周数获取日期范围c#

      时间:2023-08-26

      <small id='BP8Xn'></small><noframes id='BP8Xn'>

        <i id='BP8Xn'><tr id='BP8Xn'><dt id='BP8Xn'><q id='BP8Xn'><span id='BP8Xn'><b id='BP8Xn'><form id='BP8Xn'><ins id='BP8Xn'></ins><ul id='BP8Xn'></ul><sub id='BP8Xn'></sub></form><legend id='BP8Xn'></legend><bdo id='BP8Xn'><pre id='BP8Xn'><center id='BP8Xn'></center></pre></bdo></b><th id='BP8Xn'></th></span></q></dt></tr></i><div id='BP8Xn'><tfoot id='BP8Xn'></tfoot><dl id='BP8Xn'><fieldset id='BP8Xn'></fieldset></dl></div>
        <tfoot id='BP8Xn'></tfoot>
      1. <legend id='BP8Xn'><style id='BP8Xn'><dir id='BP8Xn'><q id='BP8Xn'></q></dir></style></legend>
          <tbody id='BP8Xn'></tbody>

          • <bdo id='BP8Xn'></bdo><ul id='BP8Xn'></ul>
                本文介绍了按周数获取日期范围c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                可能重复:
                在 .net 中,了解周数如何获取工作日日期?

                你好,

                我有一个问题要问你们.如何获取给定周数的日期范围.

                I've got a question for ya'll. How do i get the date range of a given week number.

                例如:如果我进入第 12 周,输出应该是:

                For example: If I enter week 12 the output should be:

                21-03-2011
                22-03-2011
                23-03-2011
                24-03-2011
                25-03-2011
                26-03-2011
                27-03-2011
                

                我真的希望你们能帮帮我,我只是在任何地方都找不到遮阳篷!

                I really hope you guys can help me out, i just cant find the awnser anywhere!

                提前致谢.

                推荐答案

                注意

                我似乎错过了错误.当前代码已于 2012 年 1 月 30 日更新以说明这一事实,我们现在根据 Mikael Svenson 似乎解决了这个问题.

                Note

                I appear to have missed bug. The current code have been updated as of 2012-01-30 to account for this fact and we now derive the daysOffset based on Tuesday which according to Mikael Svenson appears to solve the problem.

                这些 ISO8601 周日期计算有点不靠谱,但你是这样做的:

                These ISO8601 week date calculations are a bit wonky, but this is how you do it:

                DateTime jan1 = new DateTime(yyyy, 1, 1); 
                
                int daysOffset = DayOfWeek.Tuesday - jan1.DayOfWeek; 
                
                DateTime firstMonday = jan1.AddDays(daysOffset); 
                
                var cal = CultureInfo.CurrentCulture.Calendar; 
                
                int firstWeek = cal.GetWeekOfYear(jan1, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
                
                var weekNum = ww;
                
                if (firstWeek <= 1) 
                { 
                    weekNum -= 1; 
                }
                
                var result = firstMonday.AddDays(weekNum * 7 + d - 1);
                
                return result;
                

                基本上计算一个参考点,然后加上天,困难的事情与第 53 周有时可能发生在 1 月而第 1 周有时可能发生在 12 月这一事实有关.您需要对此进行调整,这是一种方法.

                Basically calculate a reference point, then add days, the hard stuff has to do with the fact that week 53 can sometimes occur in January and week 1 can sometimes occur in December. You need to adjust for that and this is one way to do that.

                上面的代码计算了一年的日期(yyyy)和周数(ww)和星期几(d).

                The above code calculates the date off a year (yyyy) and week number (ww) and day of week (d).

                这篇关于按周数获取日期范围c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:.net 中 ics 文件的解析器 下一篇:在 asp.net 中收到阿拉伯日期时间错误

                相关文章

                最新文章

                    • <bdo id='INATU'></bdo><ul id='INATU'></ul>
                    <i id='INATU'><tr id='INATU'><dt id='INATU'><q id='INATU'><span id='INATU'><b id='INATU'><form id='INATU'><ins id='INATU'></ins><ul id='INATU'></ul><sub id='INATU'></sub></form><legend id='INATU'></legend><bdo id='INATU'><pre id='INATU'><center id='INATU'></center></pre></bdo></b><th id='INATU'></th></span></q></dt></tr></i><div id='INATU'><tfoot id='INATU'></tfoot><dl id='INATU'><fieldset id='INATU'></fieldset></dl></div>

                    <small id='INATU'></small><noframes id='INATU'>

                  1. <legend id='INATU'><style id='INATU'><dir id='INATU'><q id='INATU'></q></dir></style></legend>

                    <tfoot id='INATU'></tfoot>