Example #1
0
        public void TryFormat_Converting_Date_To_Week_Expected_WeekofTheSpecifiedDataReturned()
        {
            string       result;
            string       error;
            const string inputString  = "06-01-2013";
            const string formatString = "dd-mm-yyyy";

            IDateTimeFormatter   dateTimeFormatter = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult    = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "w", "", 0, "");

            dateTimeFormatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2");
        }
        public void TryFormat_Converting_Date_To_ww_Expected_WeekReturnedInDoubleDigitFormat()
        {
            string result;
            string error;
            string inputString  = "06-01-2013";
            string formatString = "dd-mm-yyyy";

            IDateTimeFormatter   formatter      = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "ww", "", 0, "");

            formatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "02");
        }
Example #3
0
        public void TimeModifiers_Blank_Positive_Expected_No_Change()
        {
            string       result;
            string       error;
            const string inputString  = "2012/02/15 11:21:51 AM";
            const string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            IDateTimeFormatter   dateTimeFormatter = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult    = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "", 25, "");

            dateTimeFormatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2012/02/15 11:21:51 AM");
        }
        public void TimeModifiers_Minutes_Positive_Expected_Correct_Addition()
        {
            string result;
            string error;
            string inputString  = "2025/02/15 11:21:51 AM";
            string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            IDateTimeFormatter   formatter      = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "Minutes", 2, "");

            formatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2025/02/15 11:23:51 AM");
        }
        public void TimeModifiers_Seconds_Zero_Expected_No_Change()
        {
            string result;
            string error;
            string inputString  = "2025/02/15 11:21:51 AM";
            string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            IDateTimeFormatter   formatter      = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "Seconds", 0, "");

            formatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2025/02/15 11:21:51 AM");
        }
        public void TimeModifiers_Split_Secs_Negative_Expected_Correct_Subtraction()
        {
            string result;
            string error;
            string inputString  = "2025/02/15 11:21:51 AM";
            string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            IDateTimeFormatter   formatter      = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "Split Secs", -1000, "");

            formatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2025/02/15 11:21:50 AM");
        }
Example #7
0
        /// <summary>
        ///		Creates a new globalization context.
        /// </summary>
        /// <param name="locale">
        ///		The globalization context locale.
        /// </param>
        /// <param name="domain">
        ///		The globalization context domain.
        /// </param>
        /// <param name="currencyRepository">
        ///		The globalization context currency repository.
        /// </param>
        /// <param name="messageRepository">
        ///		The globalization context message repository.
        /// </param>
        internal GlobalizationContext(ILocale locale, string domain, ICurrencyRepository currencyRepository, IMessageRepository messageRepository)
        {
            Locale = locale ?? throw new ArgumentNullException(nameof(locale));
            Domain = domain ?? throw new ArgumentNullException(nameof(domain));

            _currencyRepository = currencyRepository ?? throw new ArgumentNullException(nameof(currencyRepository));
            _messageRepository  = messageRepository ?? throw new ArgumentNullException(nameof(messageRepository));

            _currencyFormatter = new CurrencyFormatter();
            _dateTimeFormatter = new DateTimeFormatter();
            _messageFormatter  = new MessageFormatter();
            _numberFormatter   = new NumberFormatter();
        }
 public EditBattingScorecardSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory umbracoDatabaseFactory, ServiceContext serviceContext,
                                              AppCaches appCaches, ILogger logger, IProfilingLogger profilingLogger, UmbracoHelper umbracoHelper, IMatchDataSource matchDataSource, IMatchRepository matchRepository,
                                              IAuthorizationPolicy <Stoolball.Matches.Match> authorizationPolicy, IDateTimeFormatter dateTimeFormatter, IMatchInningsUrlParser matchInningsUrlParser,
                                              IPlayerInningsScaffolder playerInningsScaffolder, IBowlingFiguresCalculator bowlingFiguresCalculator)
     : base(umbracoContextAccessor, umbracoDatabaseFactory, serviceContext, appCaches, logger, profilingLogger, umbracoHelper)
 {
     _matchDataSource          = matchDataSource ?? throw new ArgumentNullException(nameof(matchDataSource));
     _matchRepository          = matchRepository ?? throw new ArgumentNullException(nameof(matchRepository));
     _authorizationPolicy      = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _dateTimeFormatter        = dateTimeFormatter ?? throw new ArgumentNullException(nameof(dateTimeFormatter));
     _matchInningsUrlParser    = matchInningsUrlParser ?? throw new ArgumentNullException(nameof(matchInningsUrlParser));
     _playerInningsScaffolder  = playerInningsScaffolder ?? throw new ArgumentNullException(nameof(playerInningsScaffolder));
     _bowlingFiguresCalculator = bowlingFiguresCalculator ?? throw new ArgumentNullException(nameof(bowlingFiguresCalculator));
 }
 public DeleteTournamentSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory umbracoDatabaseFactory, ServiceContext serviceContext,
                                          AppCaches appCaches, ILogger logger, IProfilingLogger profilingLogger, UmbracoHelper umbracoHelper, ITournamentDataSource tournamentDataSource,
                                          IMatchListingDataSource matchListingDataSource, ITournamentRepository tournamentRepository, ICacheClearer <Tournament> cacheClearer,
                                          ICommentsDataSource <Tournament> matchCommentsDataSource, IAuthorizationPolicy <Tournament> authorizationPolicy, IDateTimeFormatter dateTimeFormatter)
     : base(umbracoContextAccessor, umbracoDatabaseFactory, serviceContext, appCaches, logger, profilingLogger, umbracoHelper)
 {
     _tournamentDataSource   = tournamentDataSource ?? throw new ArgumentNullException(nameof(tournamentDataSource));
     _matchListingDataSource = matchListingDataSource ?? throw new ArgumentNullException(nameof(matchListingDataSource));
     _tournamentRepository   = tournamentRepository ?? throw new ArgumentNullException(nameof(tournamentRepository));
     _cacheClearer           = cacheClearer ?? throw new ArgumentNullException(nameof(cacheClearer));
     _commentsDataSource     = matchCommentsDataSource ?? throw new ArgumentNullException(nameof(matchCommentsDataSource));
     _authorizationPolicy    = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _dateTimeFormatter      = dateTimeFormatter ?? throw new ArgumentNullException(nameof(dateTimeFormatter));
 }
Example #10
0
 public EditStartOfPlaySurfaceController(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory umbracoDatabaseFactory, ServiceContext serviceContext,
                                         AppCaches appCaches, ILogger logger, IProfilingLogger profilingLogger, UmbracoHelper umbracoHelper, IMatchDataSource matchDataSource,
                                         IMatchRepository matchRepository, ISeasonDataSource seasonDataSource, IAuthorizationPolicy <Match> authorizationPolicy, IDateTimeFormatter dateTimeFormatter,
                                         IEditMatchHelper editMatchHelper, ICacheClearer <Match> cacheClearer)
     : base(umbracoContextAccessor, umbracoDatabaseFactory, serviceContext, appCaches, logger, profilingLogger, umbracoHelper)
 {
     _matchDataSource     = matchDataSource ?? throw new ArgumentNullException(nameof(matchDataSource));
     _matchRepository     = matchRepository ?? throw new ArgumentNullException(nameof(matchRepository));
     _seasonDataSource    = seasonDataSource ?? throw new ArgumentNullException(nameof(seasonDataSource));
     _authorizationPolicy = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _dateTimeFormatter   = dateTimeFormatter ?? throw new ArgumentNullException(nameof(dateTimeFormatter));
     _editMatchHelper     = editMatchHelper ?? throw new ArgumentNullException(nameof(editMatchHelper));
     _cacheClearer        = cacheClearer ?? throw new ArgumentNullException(nameof(cacheClearer));
 }
Example #11
0
 public MatchActionsController(IGlobalSettings globalSettings,
                               IUmbracoContextAccessor umbracoContextAccessor,
                               ServiceContext serviceContext,
                               AppCaches appCaches,
                               IProfilingLogger profilingLogger,
                               UmbracoHelper umbracoHelper,
                               IMatchDataSource matchDataSource,
                               IAuthorizationPolicy <Match> authorizationPolicy,
                               IDateTimeFormatter dateFormatter)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _matchDataSource     = matchDataSource ?? throw new System.ArgumentNullException(nameof(matchDataSource));
     _authorizationPolicy = authorizationPolicy ?? throw new System.ArgumentNullException(nameof(authorizationPolicy));
     _dateFormatter       = dateFormatter ?? throw new System.ArgumentNullException(nameof(dateFormatter));
 }
Example #12
0
 public EditTournamentController(IGlobalSettings globalSettings,
                                 IUmbracoContextAccessor umbracoContextAccessor,
                                 ServiceContext serviceContext,
                                 AppCaches appCaches,
                                 IProfilingLogger profilingLogger,
                                 UmbracoHelper umbracoHelper,
                                 ITournamentDataSource tournamentDataSource,
                                 IAuthorizationPolicy <Tournament> authorizationPolicy,
                                 IDateTimeFormatter dateFormatter)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _tournamentDataSource = tournamentDataSource ?? throw new ArgumentNullException(nameof(tournamentDataSource));
     _authorizationPolicy  = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _dateFormatter        = dateFormatter ?? throw new ArgumentNullException(nameof(dateFormatter));
 }
        public static JsonObject timeUnitsJson()
        {
            IDateTimeFormatter dtf = KSPUtil.dateTimeFormatter;

            if (dtf == null)
            {
                return(null);
            }
            JsonObject json = new JsonObject();

            json.Add("Year", dtf.Year);
            json.Add("Day", dtf.Day);
            json.Add("Hour", dtf.Hour);
            json.Add("Minute", dtf.Minute);
            return(json);
        }
 public MatchesController(IGlobalSettings globalSettings,
                          IUmbracoContextAccessor umbracoContextAccessor,
                          ServiceContext serviceContext,
                          AppCaches appCaches,
                          IProfilingLogger profilingLogger,
                          UmbracoHelper umbracoHelper,
                          IMatchListingDataSource matchesDataSource,
                          IDateTimeFormatter dateTimeFormatter,
                          IMatchFilterQueryStringParser matchFilterQueryStringParser,
                          IMatchFilterHumanizer matchFilterHumanizer)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _matchesDataSource            = matchesDataSource ?? throw new ArgumentNullException(nameof(matchesDataSource));
     _dateTimeFormatter            = dateTimeFormatter ?? throw new ArgumentNullException(nameof(dateTimeFormatter));
     _matchFilterQueryStringParser = matchFilterQueryStringParser ?? throw new ArgumentNullException(nameof(matchFilterQueryStringParser));
     _matchFilterHumanizer         = matchFilterHumanizer ?? throw new ArgumentNullException(nameof(matchFilterHumanizer));
 }
        public static string Duration(double seconds, int secondSigd = 0)
        {
            double secondsLeft = seconds;
            int    years       = 0;
            int    days        = 0;
            int    hours       = 0;
            int    minutes     = 0;

            IDateTimeFormatter formatter = KSPUtil.dateTimeFormatter;

            years        = (int)(secondsLeft / formatter.Year);
            secondsLeft -= ((double)years) * formatter.Year; // cast is to keep from int overflow

            days         = (int)(secondsLeft / formatter.Day);
            secondsLeft -= days * formatter.Day;

            hours        = (int)(secondsLeft / formatter.Hour);
            secondsLeft -= hours * formatter.Hour;

            minutes      = (int)(secondsLeft / formatter.Minute);
            secondsLeft -= minutes * formatter.Minute;

            string secondFormat = secondSigd > 0 ? string.Format("00.{0}", new string('#', secondSigd)) : "00";

            string formatted = string.Format("{0}:{1}s", minutes.ToString("00"), secondsLeft.ToString(secondFormat));

            if (hours > 0)
            {
                formatted = string.Format("{0}:", hours) + formatted;
            }

            if (days > 0)
            {
                formatted = string.Format("{0}d ", days) + formatted;
            }

            if (years > 0)
            {
                formatted = string.Format("{0}y ", years) + formatted;
            }

            return(formatted);
        }
Example #16
0
 public EditStartOfPlayController(IGlobalSettings globalSettings,
                                  IUmbracoContextAccessor umbracoContextAccessor,
                                  ServiceContext serviceContext,
                                  AppCaches appCaches,
                                  IProfilingLogger profilingLogger,
                                  UmbracoHelper umbracoHelper,
                                  IMatchDataSource matchDataSource,
                                  ISeasonDataSource seasonDataSource,
                                  IAuthorizationPolicy <Match> authorizationPolicy,
                                  IDateTimeFormatter dateFormatter,
                                  IEditMatchHelper editMatchHelper)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _matchDataSource     = matchDataSource ?? throw new ArgumentNullException(nameof(matchDataSource));
     _seasonDataSource    = seasonDataSource ?? throw new ArgumentNullException(nameof(seasonDataSource));
     _authorizationPolicy = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _dateFormatter       = dateFormatter ?? throw new ArgumentNullException(nameof(dateFormatter));
     _editMatchHelper     = editMatchHelper ?? throw new ArgumentNullException(nameof(editMatchHelper));
 }
 public DeleteTournamentController(IGlobalSettings globalSettings,
                                   IUmbracoContextAccessor umbracoContextAccessor,
                                   ServiceContext serviceContext,
                                   AppCaches appCaches,
                                   IProfilingLogger profilingLogger,
                                   UmbracoHelper umbracoHelper,
                                   ITournamentDataSource tournamentDataSource,
                                   IMatchListingDataSource matchDataSource,
                                   ICommentsDataSource <Tournament> tournamentCommentsDataSource,
                                   IAuthorizationPolicy <Tournament> authorizationPolicy,
                                   IDateTimeFormatter dateFormatter)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _tournamentDataSource         = tournamentDataSource ?? throw new System.ArgumentNullException(nameof(tournamentDataSource));
     _matchDataSource              = matchDataSource ?? throw new ArgumentNullException(nameof(matchDataSource));
     _tournamentCommentsDataSource = tournamentCommentsDataSource;
     _authorizationPolicy          = authorizationPolicy;
     _dateFormatter = dateFormatter ?? throw new ArgumentNullException(nameof(dateFormatter));
 }
 public MatchesForSeasonController(IGlobalSettings globalSettings,
                                   IUmbracoContextAccessor umbracoContextAccessor,
                                   ServiceContext serviceContext,
                                   AppCaches appCaches,
                                   IProfilingLogger profilingLogger,
                                   UmbracoHelper umbracoHelper,
                                   IMatchFilterFactory matchFilterFactory,
                                   ISeasonDataSource seasonDataSource,
                                   IMatchListingDataSource matchDataSource,
                                   IAuthorizationPolicy <Competition> authorizationPolicy,
                                   IDateTimeFormatter dateFormatter)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _matchFilterFactory  = matchFilterFactory ?? throw new ArgumentNullException(nameof(matchFilterFactory));
     _seasonDataSource    = seasonDataSource ?? throw new ArgumentNullException(nameof(seasonDataSource));
     _matchDataSource     = matchDataSource ?? throw new ArgumentNullException(nameof(matchDataSource));
     _authorizationPolicy = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _dateFormatter       = dateFormatter ?? throw new ArgumentNullException(nameof(dateFormatter));
 }
 public EditBattingScorecardController(IGlobalSettings globalSettings,
                                       IUmbracoContextAccessor umbracoContextAccessor,
                                       ServiceContext serviceContext,
                                       AppCaches appCaches,
                                       IProfilingLogger profilingLogger,
                                       UmbracoHelper umbracoHelper,
                                       IMatchDataSource matchDataSource,
                                       IAuthorizationPolicy <Match> authorizationPolicy,
                                       IDateTimeFormatter dateFormatter,
                                       IMatchInningsUrlParser matchInningsUrlParser,
                                       IPlayerInningsScaffolder playerInningsScaffolder)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _matchDataSource         = matchDataSource ?? throw new ArgumentNullException(nameof(matchDataSource));
     _authorizationPolicy     = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _dateFormatter           = dateFormatter ?? throw new ArgumentNullException(nameof(dateFormatter));
     _matchInningsUrlParser   = matchInningsUrlParser ?? throw new ArgumentNullException(nameof(matchInningsUrlParser));
     _playerInningsScaffolder = playerInningsScaffolder ?? throw new ArgumentNullException(nameof(playerInningsScaffolder));
 }
 public TransientTeamController(IGlobalSettings globalSettings,
                                IUmbracoContextAccessor umbracoContextAccessor,
                                ServiceContext serviceContext,
                                AppCaches appCaches,
                                IProfilingLogger profilingLogger,
                                UmbracoHelper umbracoHelper,
                                ITeamDataSource teamDataSource,
                                IMatchListingDataSource matchDataSource,
                                IAuthorizationPolicy <Team> authorizationPolicy,
                                IDateTimeFormatter dateFormatter,
                                IEmailProtector emailProtector)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _teamDataSource      = teamDataSource ?? throw new ArgumentNullException(nameof(teamDataSource));
     _matchDataSource     = matchDataSource ?? throw new ArgumentNullException(nameof(matchDataSource));
     _authorizationPolicy = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _dateFormatter       = dateFormatter ?? throw new ArgumentNullException(nameof(dateFormatter));
     _emailProtector      = emailProtector ?? throw new ArgumentNullException(nameof(emailProtector));
 }
        public TimelineController(ICalendarItemRepository calendarItemRepository, IDateTimeFormatter dateTimeFormatter, IDateTimePassedEvaluator dateTimePassedEvaluator)
        {
            if (calendarItemRepository == null)
            {
                throw new ArgumentNullException("calendarItemRepository");
            }

            if (dateTimeFormatter == null)
            {
                throw new ArgumentNullException("dateTimeFormatter");
            }

            if (dateTimePassedEvaluator == null)
            {
                throw new ArgumentNullException("dateTimePassedEvaluator");
            }

            this.calendarItemRepository = calendarItemRepository;
            this.dateTimeFormatter = dateTimeFormatter;
            this.dateTimePassedEvaluator = dateTimePassedEvaluator;
        }
Example #22
0
 public MatchController(IGlobalSettings globalSettings,
                        IUmbracoContextAccessor umbracoContextAccessor,
                        ServiceContext serviceContext,
                        AppCaches appCaches,
                        IProfilingLogger profilingLogger,
                        UmbracoHelper umbracoHelper,
                        IMatchDataSource matchDataSource,
                        ICommentsDataSource <Match> commentsDataSource,
                        IAuthorizationPolicy <Match> authorizationPolicy,
                        IDateTimeFormatter dateFormatter,
                        IEmailProtector emailProtector,
                        IBadLanguageFilter badLanguageFilter)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _matchDataSource     = matchDataSource ?? throw new ArgumentNullException(nameof(matchDataSource));
     _commentsDataSource  = commentsDataSource ?? throw new ArgumentNullException(nameof(commentsDataSource));
     _authorizationPolicy = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _dateFormatter       = dateFormatter ?? throw new ArgumentNullException(nameof(dateFormatter));
     _emailProtector      = emailProtector ?? throw new ArgumentNullException(nameof(emailProtector));
     _badLanguageFilter   = badLanguageFilter ?? throw new ArgumentNullException(nameof(badLanguageFilter));
 }
Example #23
0
        public TimelineController(ICalendarItemRepository calendarItemRepository, IDateTimeFormatter dateTimeFormatter, IDateTimePassedEvaluator dateTimePassedEvaluator)
        {
            if (calendarItemRepository == null)
            {
                throw new ArgumentNullException("calendarItemRepository");
            }

            if (dateTimeFormatter == null)
            {
                throw new ArgumentNullException("dateTimeFormatter");
            }

            if (dateTimePassedEvaluator == null)
            {
                throw new ArgumentNullException("dateTimePassedEvaluator");
            }

            this.calendarItemRepository  = calendarItemRepository;
            this.dateTimeFormatter       = dateTimeFormatter;
            this.dateTimePassedEvaluator = dateTimePassedEvaluator;
        }
Example #24
0
 public MatchesForClubController(IGlobalSettings globalSettings,
                                 IUmbracoContextAccessor umbracoContextAccessor,
                                 ServiceContext serviceContext,
                                 AppCaches appCaches,
                                 IProfilingLogger profilingLogger,
                                 UmbracoHelper umbracoHelper,
                                 IClubDataSource clubDataSource,
                                 IMatchListingDataSource matchDataSource,
                                 IDateTimeFormatter dateFormatter,
                                 IMatchFilterFactory matchFilterFactory,
                                 IAuthorizationPolicy <Club> authorizationPolicy,
                                 IMatchFilterQueryStringParser matchFilterUrlParser,
                                 IMatchFilterHumanizer matchFilterHumanizer)
     : base(globalSettings, umbracoContextAccessor, serviceContext, appCaches, profilingLogger, umbracoHelper)
 {
     _clubDataSource               = clubDataSource ?? throw new ArgumentNullException(nameof(clubDataSource));
     _matchDataSource              = matchDataSource ?? throw new ArgumentNullException(nameof(matchDataSource));
     _dateFormatter                = dateFormatter ?? throw new ArgumentNullException(nameof(dateFormatter));
     _matchFilterFactory           = matchFilterFactory ?? throw new ArgumentNullException(nameof(matchFilterFactory));
     _authorizationPolicy          = authorizationPolicy ?? throw new ArgumentNullException(nameof(authorizationPolicy));
     _matchFilterQueryStringParser = matchFilterUrlParser ?? throw new ArgumentNullException(nameof(matchFilterUrlParser));
     _matchFilterHumanizer         = matchFilterHumanizer ?? throw new ArgumentNullException(nameof(matchFilterHumanizer));
 }
 public static void MyClassInitialize(TestContext testContext)
 {
     formatter = DateTimeConverterFactory.CreateFormatter();
 }
 public DateFormattedDataCollectionConfigProvider(
     IDateTimeFormatter dateTimeFormatter)
 {
     _dateTimeFormatter = dateTimeFormatter;
 }
Example #27
0
 public MatchFilterHumanizer(IDateTimeFormatter dateTimeFormatter)
 {
     _dateTimeFormatter = dateTimeFormatter ?? throw new System.ArgumentNullException(nameof(dateTimeFormatter));
 }
 public static void MyClassInitialize(TestContext testContext)
 {
     formatter = DateTimeConverterFactory.CreateFormatter();
 }
		public DateFormatterTest(ITestOutputHelper output)
		{
			_output = output;
			_dateTimeFormatter = new DefaultDateTimeFormatter();
		}
Example #30
0
 public static void WriteLine(this IDateTimeFormatter formatter, TextWriter writer)
 {
     formatter.Write(DateTime.UtcNow, writer);
     writer.WriteLine();
 }
Example #31
0
 public ShowProvider(IReadOnlyRepository repository,
                     IDateTimeFormatter dateTimeFormatter)
 {
     _repository        = repository;
     _dateTimeFormatter = dateTimeFormatter;
 }
Example #32
0
        protected static void AppendDateFilter(DateTimeOffset?fromDate, DateTimeOffset?untilDate, StringBuilder description, IDateTimeFormatter dateTimeFormatter)
        {
            if (dateTimeFormatter is null)
            {
                throw new ArgumentNullException(nameof(dateTimeFormatter));
            }

            if (description is null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            if (fromDate.HasValue)
            {
                description.Append(" from ").Append(dateTimeFormatter.FormatDate(fromDate.Value, false, true, false));
                if (!untilDate.HasValue)
                {
                    description.Append(" onwards");
                }
            }
            if (untilDate.HasValue)
            {
                description.Append(" up to ").Append(dateTimeFormatter.FormatDate(untilDate.Value, false, true, false));
            }
        }
Example #33
0
        protected override void ExecuteTool(IDSFDataObject dataObject)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();

            ErrorResultTO allErrors = new ErrorResultTO();

            InitializeDebug(dataObject);
            // Process if no errors
            try
            {
                IsSingleValueRule.ApplyIsSingleValueRule(Result, allErrors);

                if (dataObject.IsDebugMode())
                {
                    if (string.IsNullOrEmpty(DateTime))
                    {
                        var defaultDateTimeDebugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("System Date Time", "Input"), defaultDateTimeDebugItem);
                        AddDebugItem(new DebugItemStaticDataParams(System.DateTime.Now.ToString(CultureInfo.CurrentCulture), "="), defaultDateTimeDebugItem);
                        _debugInputs.Add(defaultDateTimeDebugItem);
                    }
                    else
                    {
                        AddDebugInputItem(new DebugEvalResult(DateTime, "Input", dataObject.Environment));
                    }
                    var cultureType = typeof(CultureInfo);
                    var fieldInfo   = cultureType.GetField("s_userDefaultCulture", BindingFlags.NonPublic | BindingFlags.Static);
                    if (fieldInfo != null)
                    {
                        var val    = fieldInfo.GetValue(CultureInfo.CurrentCulture);
                        var newCul = val as CultureInfo;
                        if (newCul != null)
                        {
                            Thread.CurrentThread.CurrentCulture = newCul;
                        }
                    }
                    var dateTimePattern = string.Format("{0} {1}", Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern, Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongTimePattern);

                    if (string.IsNullOrEmpty(InputFormat))
                    {
                        var defaultDateTimeDebugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("System Date Time Format", "Input Format"), defaultDateTimeDebugItem);
                        AddDebugItem(new DebugItemStaticDataParams(dateTimePattern, "="), defaultDateTimeDebugItem);
                        _debugInputs.Add(defaultDateTimeDebugItem);
                    }
                    else
                    {
                        AddDebugInputItem(new DebugEvalResult(InputFormat, "Input Format", dataObject.Environment));
                    }

                    var debugItem = new DebugItem();
                    AddDebugItem(new DebugItemStaticDataParams(TimeModifierType, "Add Time"), debugItem);
                    AddDebugItem(new DebugEvalResult(TimeModifierAmountDisplay, "", dataObject.Environment), debugItem);
                    _debugInputs.Add(debugItem);

                    if (string.IsNullOrEmpty(OutputFormat))
                    {
                        var defaultDateTimeDebugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("System Date Time Format", "Output Format"), defaultDateTimeDebugItem);
                        AddDebugItem(new DebugItemStaticDataParams(dateTimePattern, "="), defaultDateTimeDebugItem);
                        _debugInputs.Add(defaultDateTimeDebugItem);
                    }
                    else
                    {
                        AddDebugInputItem(new DebugEvalResult(OutputFormat, "Output Format", dataObject.Environment));
                    }
                }

                if (DataListUtil.HasNegativeIndex(InputFormat))
                {
                    allErrors.AddError(string.Format("Negative Recordset Index for Input Format: {0}", InputFormat));
                }
                if (DataListUtil.HasNegativeIndex(OutputFormat))
                {
                    allErrors.AddError(string.Format("Negative Recordset Index for Output Format: {0}", OutputFormat));
                }

                if (DataListUtil.HasNegativeIndex(TimeModifierAmountDisplay))
                {
                    allErrors.AddError(string.Format("Negative Recordset Index for Add Time: {0}", TimeModifierAmountDisplay));
                }
                if (!allErrors.HasErrors())
                {
                    var colItr = new WarewolfListIterator();

                    var dtItr = CreateDataListEvaluateIterator(string.IsNullOrEmpty(DateTime) ? GlobalConstants.CalcExpressionNow : DateTime, dataObject.Environment);
                    colItr.AddVariableToIterateOn(dtItr);
                    var ifItr = CreateDataListEvaluateIterator(InputFormat, dataObject.Environment);
                    colItr.AddVariableToIterateOn(ifItr);
                    var ofItr = CreateDataListEvaluateIterator(OutputFormat, dataObject.Environment);
                    colItr.AddVariableToIterateOn(ofItr);
                    var tmaItr = CreateDataListEvaluateIterator(TimeModifierAmountDisplay, dataObject.Environment);
                    colItr.AddVariableToIterateOn(tmaItr);

                    if (!allErrors.HasErrors())
                    {
                        while (colItr.HasMoreData())
                        {
                            IDateTimeOperationTO transObj = ConvertToDateTimeTo(colItr.FetchNextValue(dtItr),
                                                                                colItr.FetchNextValue(ifItr),
                                                                                colItr.FetchNextValue(ofItr),
                                                                                TimeModifierType,
                                                                                colItr.FetchNextValue(tmaItr)
                                                                                );

                            IDateTimeFormatter format = DateTimeConverterFactory.CreateFormatter();
                            string             result;
                            string             error;
                            if (format.TryFormat(transObj, out result, out error))
                            {
                                string expression = Result;
                                dataObject.Environment.Assign(expression, result);
                            }
                            else
                            {
                                allErrors.AddError(error);
                            }
                        }
                        if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                        {
                            AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFDateTime", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfDateTimeActivity", allErrors);
                    var errorString = allErrors.MakeDisplayReady();
                    dataObject.Environment.AddError(errorString);
                }
                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        AddDebugOutputItem(new DebugItemStaticDataParams("", Result, ""));
                    }
                    DispatchDebugState(dataObject, StateType.Before);
                    DispatchDebugState(dataObject, StateType.After);
                }
            }
        }