Ejemplo n.º 1
0
        public static DateTime GetExpirationDate(Services.MasterData.IMasterData masterdata, evolib.Challenge.Type type, DateTime today)
        {
            var expirationMaster = masterdata.GetChallengeExpiration(type);

            if (expirationMaster == null)
            {
                return(DateTime.MaxValue);
            }

            var finishDate = new DateTime(today.Year, today.Month, today.Day);

            switch (type)
            {
            case Challenge.Type.Beginner:
                finishDate = DateTime.MaxValue;
                break;

            case Challenge.Type.Daily:
            {
                finishDate += expirationMaster.expirationOffsetTime;

                //終了日より未来なら、終了日に次の日を指定する
                if (finishDate <= today)
                {
                    finishDate = finishDate.AddHours(24);
                }
            }
            break;

            case Challenge.Type.Weekly:
            {
                // 終了曜日算出の為、一旦日曜日に設定する
                var sundayAddDays = (int)System.DayOfWeek.Sunday - (int)finishDate.DayOfWeek;
                finishDate = finishDate.AddDays(sundayAddDays);

                finishDate += expirationMaster.expirationOffsetTime;

                //終了曜日より未来なら、終了日に次週を指定する
                if (finishDate <= today)
                {
                    finishDate = finishDate.AddHours(7 * 24);
                }
            }
            break;
            }

            return(finishDate);
        }
Ejemplo n.º 2
0
 public IChallengeExpiration GetChallengeExpiration(evolib.Challenge.Type challengeType)
 {
     return((_ChallengeExpirationMap.ContainsKey(challengeType)) ? (_ChallengeExpirationMap[challengeType]) : (null));
 }