public override string AsString() { string resultTimeString = ""; if (NumberOfPointsInUse > 0) { resultTimeString += DayInMonthValue.ToString("D2"); } if (NumberOfPointsInUse > 1) { resultTimeString += "."; resultTimeString += MonthValue.ToString("D2");; } if (NumberOfPointsInUse > 2) { resultTimeString += "."; resultTimeString += "20" + YearValue.ToString("D2"); } if (NumberOfPointsInUse > 3) { resultTimeString += " "; resultTimeString += HoursValue.ToString("D2");; } if (NumberOfPointsInUse > 4) { resultTimeString += ":"; resultTimeString += MinutesValue.ToString("D2");; } if (NumberOfPointsInUse > 5) { resultTimeString += ":"; resultTimeString += SecondsValue.ToString("D2");; } if (NumberOfPointsInUse > 6) { resultTimeString += ","; resultTimeString += MillisecondsValue.ToString("D" + MillisecondsDecimalsPlaces); } return(resultTimeString); }
/// <summary> /// Validates that today is allowed date to perform action based on year, month and allowed input days. /// </summary> /// <param name="yearValue">The year value.</param> /// <param name="monthValue">The month value.</param> /// <param name="inputAllowedInDays">The allowed input in days.</param> /// <exception cref="BusinessProcessingException"> /// If current action is forbidden due to restriction of input allowed days. /// </exception> /// <exception cref="ArgumentException"> /// If <paramref name="yearValue"/> or <paramref name="monthValue"/> is null or cannot be parsed. /// </exception> internal static void ValidateTodayIsAllowedUpdateDate( YearValue yearValue, MonthValue monthValue, int inputAllowedInDays) { try { int month = DateTime.ParseExact(monthValue?.Value, "MMMM", CultureInfo.InvariantCulture).Month; int year = Convert.ToInt32(yearValue?.Value); DateTime maxDate = new DateTime(year, month, 1).AddDays(inputAllowedInDays); if (DateTime.Today > maxDate) { throw new BusinessProcessingException( "Current action is forbidden due to restriction of input allowed days."); } } catch (BusinessProcessingException) { throw; } catch (Exception ex) { throw new ArgumentException( $"Either Year='{yearValue?.Value}' or Month='{monthValue?.Value}' is invalid.", ex); } }