Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

محاسبه تاریخ 10 روز کاری آینده #17

Open
PouryaRajaei opened this issue Jul 13, 2024 · 0 comments
Open

محاسبه تاریخ 10 روز کاری آینده #17

PouryaRajaei opened this issue Jul 13, 2024 · 0 comments

Comments

@PouryaRajaei
Copy link

PouryaRajaei commented Jul 13, 2024

سلام و وقت بخیر
خیلی از افراد نیاز دارن که محاسبه بشه مثلا 10 روز کاری آینده از امروز میشه چندم !؟

پیشنهاد میشه از متدی استفاده بشه که فقط کاربر بنویسه چند روز کاری ، و خودش حساب کنه از روز جای مثلا 5 روز کاری آینده چه تاریخی میشه

نمونه کدی که نوشتم


 public static string AddWorkingDays(int workingDays, bool includeThursdays = false)
 {
     PersianDateTime startDate = new PersianDateTime(DateTime.Now);
     PersianDateTime endDate = new PersianDateTime(DateTime.Now.AddYears(1));
     if (startDate > endDate)
     {
         PersianDateTime persianDateTime = startDate;
         startDate = endDate;
         endDate = persianDateTime;
     }

     PersianDateTime persianDateTime2 = new PersianDateTime(startDate);
     int num = 0;
     for (; persianDateTime2 <= endDate; ++persianDateTime2)
     {
         if (!persianDateTime2.IsHoliDay && (persianDateTime2.DateTime.DayOfWeek != DayOfWeek.Thursday || includeThursdays))
         {
             num++;
             if(workingDays == num)
             {
                 return persianDateTime2.ShamsiDate;
             }
         }
     }

     return "error";
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant