コード例 #1
0
        public static DateTimeOffset?GetNextExecution(IScheduleInfo config, DateTimeOffset now, TimeZoneInfo timeZone)
        {
            if (config.StartTime != null)
            {
                // if the start time is in future
                if (config.StartTime > now)
                {
                    return(config.StartTime.Value);
                }
            }

            if (config.ScheduleCron != null)
            {
                return(CronYearParser.GetNextOccurrence(config.ScheduleCron, now, timeZone));
            }

            // there is no next execution
            return(null);
        }
コード例 #2
0
ファイル: ConferenceScheduler.cs プロジェクト: Anapher/Strive
        public DateTimeOffset?GetNextExecution(IScheduleInfo config)
        {
            var now = DateTimeOffset.UtcNow;

            TimeZoneInfo timeZone;

            try
            {
                timeZone = TimeZoneInfo.FindSystemTimeZoneById(_options.Value.CronTimezone);
            }
            catch (Exception e)
            {
                timeZone = TimeZoneInfo.Local;
                _logger.LogWarning(e,
                                   "Error occurred on finding the time zone \"{timeZone}\". Please make sure to select a valid time zone. Local time zone ({local}) is used.",
                                   _options.Value.CronTimezone, timeZone);
            }

            return(ScheduleUtils.GetNextExecution(config, now, timeZone));
        }