public AxcExt(IStreamReader reader, RecordType id, ushort length) : base(reader, id, length) { // assert that the correct record type is instantiated Debug.Assert(this.Id == ID); // initialize class members from stream this.catMin = reader.ReadUInt16(); this.catMax = reader.ReadUInt16(); this.catMajor = reader.ReadUInt16(); this.duMajor = (DateUnit)reader.ReadUInt16(); this.catMinor = reader.ReadUInt16(); this.duMinor = (DateUnit)reader.ReadUInt16(); this.duBase = (DateUnit)reader.ReadUInt16(); this.catCrossDate = reader.ReadUInt16(); ushort flags = reader.ReadUInt16(); this.fAutoMin = Utils.BitmaskToBool(flags, 0x0001); this.fAutoMax = Utils.BitmaskToBool(flags, 0x0002); this.fAutoMajor = Utils.BitmaskToBool(flags, 0x0004); this.fAutoMinor = Utils.BitmaskToBool(flags, 0x0008); this.fDateAxis = Utils.BitmaskToBool(flags, 0x0010); this.fAutoBase = Utils.BitmaskToBool(flags, 0x0020); this.fAutoCross = Utils.BitmaskToBool(flags, 0x0040); this.fAutoDate = Utils.BitmaskToBool(flags, 0x0080); // assert that the correct number of bytes has been read from the stream Debug.Assert(this.Offset + this.Length == this.Reader.BaseStream.Position); }
/// <summary> /// Construct a <see cref="ScaleState"/> from the specified <see cref="Axis"/> /// </summary> /// <param name="axis">The <see cref="Axis"/> from which to collect the scale /// range settings.</param> public ScaleState(Axis axis) { _min = axis._scale._min; if (double.IsNaN(_min)) { throw new ApplicationException("_min is NaN"); } _minorStep = axis._scale._minorStep; _majorStep = axis._scale._majorStep; _max = axis._scale._max; _majorUnit = axis._scale._majorUnit; _minorUnit = axis._scale._minorUnit; _format = axis._scale._format; _mag = axis._scale._mag; //this.numDec = axis.NumDec; _minAuto = axis._scale._minAuto; _majorStepAuto = axis._scale._majorStepAuto; _minorStepAuto = axis._scale._minorStepAuto; _maxAuto = axis._scale._maxAuto; _formatAuto = axis._scale._formatAuto; _magAuto = axis._scale._magAuto; }
public static Offset <Date> CreateDate(FlatBufferBuilder builder, DateUnit unit = DateUnit.MILLISECOND) { builder.StartObject(1); Date.AddUnit(builder, unit); return(Date.EndDate(builder)); }
private static void OnDateRangeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { //DateRangePickerに新しいDateRangeがセットされときによびだされる。 DateRangePicker2 dateRangePicker = (DateRangePicker2)sender; DateRange oldDateRange = (DateRange)e.OldValue; DateRange newDateRange = (DateRange)e.NewValue; if (DateRange.EqualsDateRange(oldDateRange, newDateRange)) { return; } DateUnit fromDate = newDateRange.FromDate; dateRangePicker.FromYear = fromDate.Year.ToString(); dateRangePicker.FromMonth = fromDate.Month.ToString(); dateRangePicker.FromDay = fromDate.Day.ToString(); DateUnit toDate = newDateRange.ToDate; dateRangePicker.ToYear = toDate.Year.ToString(); dateRangePicker.ToMonth = toDate.Month.ToString(); dateRangePicker.ToDay = toDate.Day.ToString(); //DateRangePickerの変更を監視しているオブジェクトに変更を通知。 dateRangePicker.OnDateRangeChanged(oldDateRange, newDateRange); }
public void FillDateDownTo(DateTime dt, DateUnit value) { SetDate(dt.Year, value != DateUnit.Year ? dt.Month : _month, value != DateUnit.Year && value != DateUnit.Month ? dt.Day : _day); OnPropertyChanged("Year", "Month", "Day"); }
public Scale(Axis ownerAxis) { _ownerAxis = ownerAxis; _min = 0.0; _max = 1.0; _majorStep = 0.1; _minorStep = 0.1; _exponent = 1.0; _minAuto = true; _maxAuto = true; _majorStepAuto = true; _minorStepAuto = true; _magAuto = true; _formatAuto = true; _isVisible = true; _isMinLabelVisible = true; _isMaxLabelVisible = true; _majorUnit = DateUnit.Day; _minorUnit = DateUnit.Day; _format = null; _textLabels = null; }
public void increaseUnit(DateUnit unit, int value) { int unitLimit; switch (unit) { case DateUnit.Year: unitLimit = Int32.MaxValue; break; case DateUnit.Day: unitLimit = getNumberOfDaysInMonth(); break; default: unitLimit = dateUnitLimits[(int)unit]; break; } int existingValue = units[(int)unit]; int newValue = existingValue + value; if (newValue > unitLimit) { units[(int)unit] = newValue - unitLimit; //Now increase the previous unit's value. int previousUnit = ((int)unit) - 1; increaseUnit((DateUnit)previousUnit, 1); } else { units[(int)unit] = newValue; } }
private void SpawnDate() { if (!LevelDataManager.Instance.TryGetNPCSpawnPoint(DateSpawnPointId, out Transform spawnpoint)) { CustomLogger.Error(nameof(DateStateManager), $"Could not find spawnpoint with id \"{DateSpawnPointId}\""); return; } if (!PooledObjectManager.Instance.UsePooledObject(_dateData.UnitPrefabId, out PooledObject pooledObject)) { CustomLogger.Error(nameof(DateStateManager), $"Could not retrieve pooled object with id \"{_dateData.UnitPrefabId}\""); return; } DateInitializationData initData = new DateInitializationData(); initData.OverrideUniqueId = _dateData.UnitPrefabId; initData.UnitData = _dateData; DateUnit dateUnit = pooledObject as DateUnit; dateUnit.Initialize(initData); dateUnit.transform.position = spawnpoint.position; dateUnit.Spawn(); dateUnit.TargetManager.OnCurrentTargetSet += OnDateCurrentTargetSet; dateUnit.OnUnitDefeated += DateDefeated; OnDateSpawned?.Invoke(); }
/// <summary> /// Internal routine to calculate a multiplier to the selected unit back to days. /// </summary> /// <param name="unit">The unit type for which the multiplier is to be /// calculated</param> /// <returns> /// This is ratio of days/selected unit /// </returns> private double GetUnitMultiple(DateUnit unit) { switch (unit) { case DateUnit.Year: default: return(365.0); case DateUnit.Month: return(30.0); case DateUnit.Day: return(1.0); case DateUnit.Hour: return(1.0 / XDate.HoursPerDay); case DateUnit.Minute: return(1.0 / XDate.MinutesPerDay); case DateUnit.Second: return(1.0 / XDate.SecondsPerDay); case DateUnit.Millisecond: return(1.0 / XDate.MillisecondsPerDay); } }
/// <summary> /// /// </summary> /// <param name="unit"></param> /// <param name="offset"></param> public virtual void SetFromDate(DateUnit unit, int offset) { var chart = this.Chart; var index = chart.Axes.IndexOf(this); chart.AddScript("{0}.axes.get({1}).fromDate=Ext.Date.add(Ext.Date.clone({0}.axes.get({1}).fromDate), Ext.Date.{2}, {3});", chart.ClientID, index, unit.ToString().ToUpperInvariant(), offset); }
public DateFilter(int notOlderThan, DateUnit measure) { this.DateComparision = Nomad.Commons.DateComparision.Ignore; this.NotOlderThan = 1; this.DateMeasure = DateUnit.Day; this.NotOlderThan = notOlderThan; this.DateMeasure = measure; this.DateComparision = Nomad.Commons.DateComparision.NotOlderThan; }
public static string ToSimpleDate(string str) { DateUnit dateUnit = ParseDateUnit(str); if (dateUnit == null) { return(""); } return(ToString(dateUnit)); }
public DateOffset(int?offset, DateUnit unit, Func <DateTime> now = null) : this() { // для тестов if (now != null) { Now = now(); } SetOffset(offset, unit); }
public RepetitionSchedule(ISchedule baseSchedule, DateUnit unit, int increment) { if (increment <= 0) { throw new ArgumentOutOfRangeException(nameof(increment)); } this.BaseSchedule = baseSchedule ?? throw new ArgumentNullException(nameof(baseSchedule)); this.Unit = unit; this.Increment = increment; }
/// <summary> /// Установка даты меняет единицу измерения и смещение на наиболее подходящие. /// </summary> public static DateOffset RoundOffsetUnitByDate(this DateOffset d, DateTime described) { Contract.Requires(d.Year != null); Contract.Ensures(d.Equals(Contract.OldValue(d))); int? offset = null; DateUnit unit = 0; Action setRoundedOffsetUnitMonthOrYear = () => { var months = DateHelper.GetTotalMonthsBetween(described, d.Year.Value, d.Month.Value); if (months < 12) // меньше года - месяцы { offset = months; unit = DateUnit.Month; } else { offset = described.Year - d.Year.Value; unit = DateUnit.Year; } }; if (d.Month == null) // _ _ y (или d _ y без автообрезания) { offset = described.Year - d.Year.Value; unit = DateUnit.Year; } else if (d.Day == null) // _ m y { setRoundedOffsetUnitMonthOrYear(); } else // d m y { var days = (described - (DateTime)d).Days; if (days < 7) // меньше недели - дни { offset = days; unit = DateUnit.Day; } else if (days < 4 * 7) // меньше месяца - недели { offset = days / 7; unit = DateUnit.Week; } else { setRoundedOffsetUnitMonthOrYear(); } } return(new DateOffset(offset, unit, () => d.Now)); }
public DateFilter(Nomad.Commons.DateComparision comparision, DateTime date) { this.DateComparision = Nomad.Commons.DateComparision.Ignore; this.NotOlderThan = 1; this.DateMeasure = DateUnit.Day; if ((comparision < Nomad.Commons.DateComparision.On) || (comparision > Nomad.Commons.DateComparision.After)) { throw new ArgumentOutOfRangeException(); } this.DateComparision = comparision; this.FromDate = date; }
/// <summary> /// Задает смещение и единицу. /// </summary> /// <param name="forceSetDateByOffsetUnit">Установка даты при задании только смещения или создании объекта.</param> private void SetOffset(int?offset, DateUnit unit) { if (inSetting.CanEnter) { using (inSetting.Enter()) { Offset = offset; Unit = unit; SetDateByOffsetUnit(); } } }
public DateFilter(Nomad.Commons.DateComparision comparision, DateTime fromDate, DateTime toDate) { this.DateComparision = Nomad.Commons.DateComparision.Ignore; this.NotOlderThan = 1; this.DateMeasure = DateUnit.Day; if ((comparision != Nomad.Commons.DateComparision.Between) && (comparision != Nomad.Commons.DateComparision.NotBetween)) { throw new ArgumentOutOfRangeException(); } this.DateComparision = comparision; this.FromDate = fromDate; this.ToDate = toDate; }
public static DateUnit ParseDateUnit(string str) { DateUnit dateUnit = null; try { dateUnit = DateParser.Parse(str); } catch (Exception) { } return(dateUnit); }
public virtual int DisplayValue(DateTime dateTime, int index) { DateUnit dateUnit = dateUnits[index]; switch (dateUnit) { case DateUnit.Day: return dateTime.Day; case DateUnit.Month: return dateTime.Month; case DateUnit.Year: return dateTime.Year; } throw new WhiteAssertionException(); }
/// <summary> /// Gets a DateTime representing the last unit of time, such as week or month. /// </summary> /// <param name="current">The current date.</param> /// <param name="dateUnit">The date unit.</param> /// <returns></returns> public static DateTime Last(this DateTime current, DateUnit dateUnit) { switch (dateUnit) { case DateUnit.Day: return current.AddDays(-1); case DateUnit.Week: return current.AddDays(-14).Next(CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek); case DateUnit.Month: return current.First().AddDays(-1).First(); case DateUnit.Year: return new DateTime(current.Year - 1,1,1); } return current; }
public RepetitionSchedule(ISchedule baseSchedule, DateUnit unit, int increment) { if (baseSchedule == null) { throw new ArgumentNullException("baseSchedule"); } if (increment <= 0) { throw new ArgumentOutOfRangeException("increment"); } this.BaseSchedule = baseSchedule; this.Unit = unit; this.Increment = increment; }
public static DateUnit GetNextDateUnit(this DateUnit unit) { switch (unit) { case DateUnit.Day: return(DateUnit.Week); case DateUnit.Week: return(DateUnit.Month); case DateUnit.Month: return(DateUnit.Year); case DateUnit.Year: return(DateUnit.Day); } throw new NotImplementedException(); }
/// <summary> /// Get a DateTime representing the current unit of time. /// </summary> /// <param name="current">The current date.</param> /// <param name="dateUnit">The date unit.</param> /// <returns></returns> public static DateTime This(this DateTime current, DateUnit dateUnit) { switch (dateUnit) { case DateUnit.Day: return(current.Midnight()); case DateUnit.Week: return(current.AddWeeks(-1).Next(CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek)); case DateUnit.Month: return(current.First()); case DateUnit.Year: return(new DateTime(current.Year, 1, 1)); } return(current); }
/// <summary> /// Gets a DateTime representing the next unit of time, such as week or month /// </summary> /// <param name="current">The current date.</param> /// <param name="dateUnit">The date unit (week,month,year,day).</param> /// <returns></returns> public static DateTime Next(this DateTime current, DateUnit dateUnit) { switch (dateUnit) { case DateUnit.Day: return(current.AddDays(1)); case DateUnit.Week: return(current.Next(CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek)); case DateUnit.Month: return(current.Last().AddDays(1)); case DateUnit.Year: return(new DateTime(current.Year + 1, 1, 1)); } return(current); }
private void AddList(Dictionary <String, FilterData> dic, DateUnit unit) { FilterData f1 = new FilterData(); IEnumerable <EntryData> querySet = from d in _filterData.EntryList where d.time > unit.Start && d.time < unit.End select d; if (querySet.Count <EntryData>() > 0) { f1.EntryList = querySet.ToList <EntryData>(); f1.DailyList = DataUtil.ConvertDailyList(f1.EntryList); //if (_type == (int)RangeType.Hourly) //{ // dic.Add(StockUtil.FormatAllTime(unit.Start, true) + "_" + StockUtil.FormatAllTime(unit.End, true), f1); // } //else //{ dic.Add(StockUtil.FormatAllTime(unit.Start) + "_" + StockUtil.FormatAllTime(unit.End), f1); // } } }
/// <summary> /// Округляет смещение. /// При укрупнении единицы смещение считается для полной даты с 1 вместо отсутствующих значений. /// </summary> public static int?RoundOffsetFor(this DateOffset d, DateUnit unit) { Contract.Requires(d != null); Contract.Ensures(d.Equals(Contract.OldValue(d))); Contract.Ensures(!d.IsEmpty || Contract.Result <int?>() == null); if (!d.Year.HasValue) { return(null); } int?roundedOffset; switch (unit) { case DateUnit.Day: roundedOffset = (d.Now - d.GetSortingDate()).Days; break; case DateUnit.Week: roundedOffset = (d.Now - d.GetSortingDate()).Days / 7; break; case DateUnit.Month: if (d.Month.HasValue) { roundedOffset = DateHelper.GetTotalMonthsBetween(d.Now, d.Year.Value, d.Month.Value); } else { roundedOffset = DateHelper.GetTotalMonthsBetween(d.Now, d.Year.Value, 1); } break; case DateUnit.Year: roundedOffset = d.Now.Year - d.Year.Value; break; default: throw new NotImplementedException(); } return(roundedOffset); }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="ScaleState"/> object from which to copy</param> public ScaleState(ScaleState rhs) { this.min = rhs.min; this.step = rhs.step; this.minorStep = rhs.minorStep; this.max = rhs.max; this.majorUnit = rhs.majorUnit; this.minorUnit = rhs.minorUnit; this.scaleFormat = rhs.scaleFormat; this.scaleMag = rhs.scaleMag; this.minAuto = rhs.minAuto; this.stepAuto = rhs.stepAuto; this.minorStepAuto = rhs.minorStepAuto; this.maxAuto = rhs.maxAuto; this.scaleFormatAuto = rhs.scaleFormatAuto; this.scaleMagAuto = rhs.scaleMagAuto; }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="ScaleState"/> object from which to copy</param> public ScaleState(ScaleState rhs) { _min = rhs._min; _majorStep = rhs._majorStep; _minorStep = rhs._minorStep; _max = rhs._max; _majorUnit = rhs._majorUnit; _minorUnit = rhs._minorUnit; _format = rhs._format; _mag = rhs._mag; _minAuto = rhs._minAuto; _majorStepAuto = rhs._majorStepAuto; _minorStepAuto = rhs._minorStepAuto; _maxAuto = rhs._maxAuto; _formatAuto = rhs._formatAuto; _magAuto = rhs._magAuto; }
public static HealthRecordUnit ToHealthRecordUnit(this DateUnit unit) { switch (unit) { case DateUnit.Day: return(HealthRecordUnit.Day); case DateUnit.Week: return(HealthRecordUnit.Week); case DateUnit.Month: return(HealthRecordUnit.Month); case DateUnit.Year: return(HealthRecordUnit.Year); default: throw new ArgumentOutOfRangeException(); } }
private static DateTime Roll(DateTime date_, int units_, DateUnit unit_, BusinessDayConvention convention_, string otCalendar_, CarbonClient client_, ThrowBehavior behavior_=ThrowBehavior.DontThrow) { try { string key = getKey(date_, units_, unit_, convention_, otCalendar_); if (_cache.ContainsKey(key)) return _cache[key]; var result = client_.RollDateAsync(date_.ToNodaLocalDate(), units_, unit_, convention_, otCalendar_).Result.ToDateTime(); _cache[key] = result; return result; } catch (Exception ex_) { Exceptions.Rethrow("Error rolling date", behavior_, ex_); } return DateTime.MinValue; }
/// <summary> /// Unit of DateOffset with ending for given offset. /// </summary> public static string GetUnitString(int?offset, DateUnit unit) { if (offset == null) { offset = 0; } int ending = PluralsHelper.GetPluralEnding(offset.Value); switch (unit) { case DateUnit.Day: return(Plurals.days[ending]); case DateUnit.Week: return(Plurals.weeks[ending]); case DateUnit.Month: return(Plurals.months[ending]); case DateUnit.Year: return(Plurals.years[ending]); } throw new ArgumentOutOfRangeException("unit"); }
/// <summary> /// Construct a <see cref="ScaleState"/> from the specified <see cref="Axis"/> /// </summary> /// <param name="axis">The <see cref="Axis"/> from which to collect the scale /// range settings.</param> public ScaleState(Axis axis) { _min = axis._scale._min; _minorStep = axis._scale._minorStep; _majorStep = axis._scale._majorStep; _max = axis._scale._max; _majorUnit = axis._scale._majorUnit; _minorUnit = axis._scale._minorUnit; _format = axis._scale._format; _mag = axis._scale._mag; //this.numDec = axis.NumDec; _minAuto = axis._scale._minAuto; _majorStepAuto = axis._scale._majorStepAuto; _minorStepAuto = axis._scale._minorStepAuto; _maxAuto = axis._scale._maxAuto; _formatAuto = axis._scale._formatAuto; _magAuto = axis._scale._magAuto; }
/// <summary> /// Construct a <see cref="ScaleState"/> from the specified <see cref="Axis"/> /// </summary> /// <param name="axis">The <see cref="Axis"/> from which to collect the scale /// range settings.</param> public ScaleState(Axis axis) { this.min = axis.Min; this.minorStep = axis.MinorStep; this.step = axis.Step; this.max = axis.Max; this.majorUnit = axis.MajorUnit; this.minorUnit = axis.MinorUnit; this.scaleFormat = axis.ScaleFormat; this.scaleMag = axis.ScaleMag; //this.numDec = axis.NumDec; this.minAuto = axis.MinAuto; this.stepAuto = axis.StepAuto; this.minorStepAuto = axis.MinorStepAuto; this.maxAuto = axis.MaxAuto; this.scaleFormatAuto = axis.ScaleFormatAuto; this.scaleMagAuto = axis.ScaleMagAuto; }
/// <summary> /// Construct a <see cref="ScaleState"/> from the specified <see cref="Axis"/> /// </summary> /// <param name="axis">The <see cref="Axis"/> from which to collect the scale /// range settings.</param> public ScaleState( Axis axis ) { _min = axis._scale._min; _minorStep = axis._scale._minorStep; _majorStep = axis._scale._majorStep; _max = axis._scale._max; _majorUnit = axis._scale._majorUnit; _minorUnit = axis._scale._minorUnit; _format = axis._scale._format; _mag = axis._scale._mag; //this.numDec = axis.NumDec; _minAuto = axis._scale._minAuto; _majorStepAuto = axis._scale._majorStepAuto; _minorStepAuto = axis._scale._minorStepAuto; _maxAuto = axis._scale._maxAuto; _formatAuto = axis._scale._formatAuto; _magAuto = axis._scale._magAuto; }
public Scale(Scale rhs, Axis owner) { _ownerAxis = owner; _min = rhs._min; _max = rhs._max; _majorStep = rhs._majorStep; _minorStep = rhs._minorStep; _exponent = rhs._exponent; _baseTic = rhs._baseTic; _minAuto = rhs._minAuto; _maxAuto = rhs._maxAuto; _majorStepAuto = rhs._majorStepAuto; _minorStepAuto = rhs._minorStepAuto; _magAuto = rhs._magAuto; _formatAuto = rhs._formatAuto; _isMinLabelVisible = rhs._isMinLabelVisible; _isMaxLabelVisible = rhs._isMaxLabelVisible; _majorUnit = rhs._majorUnit; _minorUnit = rhs._minorUnit; _format = rhs._format; _align = rhs._align; _alignH = rhs._alignH; _alignHMaxLabel = rhs._alignHMaxLabel; _alignHMinLabel = rhs._alignHMinLabel; if (rhs._textLabels != null) { _textLabels = (string[])rhs._textLabels.Clone(); } else { _textLabels = null; } }
public static string ToString(DateUnit dateUnit) { if (dateUnit == null) { return(""); } DateUnitType type = dateUnit.DateUnitType; if (type == DateUnitType.YearMonthDay) { return(dateUnit.ToYearMonthDayString()); } else if (type == DateUnitType.YearMonth) { return(dateUnit.ToYearMonthString()); } else if (type == DateUnitType.Year) { return(dateUnit.ToYearString()); } return(""); }
/// <summary> /// Basic constructor -- requires that the <see cref="Scale" /> object be intialized with /// a pre-existing owner <see cref="Axis" />. /// </summary> /// <param name="ownerAxis">The <see cref="Axis" /> object that is the owner of this /// <see cref="Scale" /> instance.</param> public Scale( Axis ownerAxis ) { _ownerAxis = ownerAxis; _min = 0.0; _max = 1.0; _majorStep = 0.1; _minorStep = 0.1; _exponent = 1.0; _mag = 0; _baseTic = PointPair.Missing; _minGrace = Default.MinGrace; _maxGrace = Default.MaxGrace; _minAuto = true; _maxAuto = true; _majorStepAuto = true; _minorStepAuto = true; _magAuto = true; _formatAuto = true; _isReverse = Default.IsReverse; _isUseTenPower = true; _isPreventLabelOverlap = true; _isVisible = true; _isSkipFirstLabel = false; _isSkipLastLabel = false; _isSkipCrossLabel = false; _majorUnit = DateUnit.Day; _minorUnit = DateUnit.Day; _format = null; _textLabels = null; _isLabelsInside = Default.IsLabelsInside; _align = Default.Align; _alignH = Default.AlignH; _fontSpec = new FontSpec( Default.FontFamily, Default.FontSize, Default.FontColor, Default.FontBold, Default.FontUnderline, Default.FontItalic, Default.FillColor, Default.FillBrush, Default.FillType ); _fontSpec.Border.IsVisible = false; _labelGap = Default.LabelGap; }
private string Write68_DateUnit(DateUnit v) { switch (v) { case DateUnit.Day: return "Day"; case DateUnit.Week: return "Week"; case DateUnit.Month: return "Month"; case DateUnit.Year: return "Year"; } long num = (long) v; throw base.CreateInvalidEnumValueException(num.ToString(CultureInfo.InvariantCulture), "Nomad.Commons.DateUnit"); }
public DateTime RollDate(DateTime date_, int units_, DateUnit unit_, BusinessDayConvention conv_, string calendar_) { return RollDate(GetClient(), date_, units_, unit_, conv_, calendar_); }
/// <summary> /// Calculate a step size for a <see cref="AxisType.Date"/> scale. /// This method is used by <see cref="PickScale"/>. /// </summary> /// <param name="range">The range of data in units of days</param> /// <param name="targetSteps">The desired "typical" number of steps /// to divide the range into</param> /// <returns>The calculated step size for the specified data range. Also /// calculates and sets the values for <see cref="MajorUnit"/>, /// <see cref="MinorUnit"/>, <see cref="MinorStep"/>, and /// <see cref="ScaleFormat"/></returns> protected double CalcDateStepSize( double range, double targetSteps ) { // Calculate an initial guess at step size double tempStep = range / targetSteps; if ( range > Default.RangeYearYear ) { majorUnit = DateUnit.Year; if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatYearYear; tempStep = Math.Ceiling( tempStep / 365.0 ); if ( tempStep < 1.0 ) tempStep = 1.0; if ( minorStepAuto ) { minorUnit = DateUnit.Year; if ( tempStep == 1.0 ) minorStep = 0.25; else minorStep = CalcStepSize( tempStep, targetSteps ); } } else if ( range > Default.RangeYearMonth ) { majorUnit = DateUnit.Year; if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatYearMonth; tempStep = 1.0; if ( minorStepAuto ) { minorUnit = DateUnit.Month; // Calculate the minor steps to give an estimated 4 steps // per major step. minorStep = Math.Ceiling( range / ( targetSteps * 3 ) / 30.0 ); // make sure the minorStep is 1, 2, 3, 6, or 12 months if ( minorStep > 6 ) minorStep = 12; else if ( minorStep > 3 ) minorStep = 6; } } else if ( range > Default.RangeMonthMonth ) { majorUnit = DateUnit.Month; if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatMonthMonth; tempStep = Math.Ceiling( tempStep / 30.0 ); if ( tempStep < 1.0 ) tempStep = 1.0; if ( minorStepAuto ) { minorUnit = DateUnit.Month; minorStep = 0.25; } } else if ( range > Default.RangeDayDay ) { majorUnit = DateUnit.Day; if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatDayDay; tempStep = Math.Ceiling( tempStep ); if ( tempStep < 1.0 ) tempStep = 1.0; if ( minorStepAuto ) { minorUnit = DateUnit.Day; minorStep = 1.0; } } else if ( range > Default.RangeDayHour ) { majorUnit = DateUnit.Day; if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatDayHour; tempStep = 1.0; if ( minorStepAuto ) { minorUnit = DateUnit.Hour; // Calculate the minor steps to give an estimated 4 steps // per major step. minorStep = Math.Ceiling( range / ( targetSteps * 3 ) * XDate.HoursPerDay ); // make sure the minorStep is 1, 2, 3, 6, or 12 hours if ( minorStep > 6 ) minorStep = 12; else if ( minorStep > 3 ) minorStep = 6; else if ( minorStep < 1 ) minorStep = 1; } } else if ( range > Default.RangeHourHour ) { majorUnit = DateUnit.Hour; tempStep = Math.Ceiling( tempStep * XDate.HoursPerDay ); if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatHourHour; if ( tempStep > 12.0 ) tempStep = 24.0; else if ( tempStep > 6.0 ) tempStep = 12.0; else if ( tempStep > 3.0 ) tempStep = 6.0; else if ( tempStep < 1.0 ) tempStep = 1.0; if ( minorStepAuto ) { minorUnit = DateUnit.Hour; minorStep = 0.25; } } else if ( range > Default.RangeHourMinute ) { majorUnit = DateUnit.Hour; tempStep = 1.0; if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatHourMinute; if ( minorStepAuto ) { minorUnit = DateUnit.Minute; // Calculate the minor steps to give an estimated 4 steps // per major step. minorStep = Math.Ceiling( range / ( targetSteps * 3 ) * XDate.MinutesPerDay ); // make sure the minorStep is 1, 5, 15, or 30 minutes if ( minorStep > 15.0 ) minorStep = 30.0; else if ( minorStep > 5.0 ) minorStep = 15.0; else if ( minorStep > 1.0 ) minorStep = 5.0; else if ( minorStep < 1.0 ) minorStep = 1.0; } } else if ( range > Default.RangeMinuteMinute ) { majorUnit = DateUnit.Minute; if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatMinuteMinute; tempStep = Math.Ceiling( tempStep * XDate.MinutesPerDay ); // make sure the minute step size is 1, 5, 15, or 30 minutes if ( tempStep > 15.0 ) tempStep = 30.0; else if ( tempStep > 5.0 ) tempStep = 15.0; else if ( tempStep > 1.0 ) tempStep = 5.0; else if ( tempStep < 1.0 ) tempStep = 1.0; if ( minorStepAuto ) { minorUnit = DateUnit.Minute; minorStep = 0.25; } } else if ( range > Default.RangeMinuteSecond ) { majorUnit = DateUnit.Minute; tempStep = 1.0; if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatMinuteSecond; if ( minorStepAuto ) { minorUnit = DateUnit.Second; // Calculate the minor steps to give an estimated 4 steps // per major step. minorStep = Math.Ceiling( range / ( targetSteps * 3 ) * XDate.SecondsPerDay ); // make sure the minorStep is 1, 5, 15, or 30 seconds if ( minorStep > 15.0 ) minorStep = 30.0; else if ( minorStep > 5.0 ) minorStep = 15.0; else if ( minorStep > 1.0 ) minorStep = 5.0; else if ( minorStep < 1.0 ) minorStep = 1.0; } } else // SecondSecond { majorUnit = DateUnit.Second; if ( this.scaleFormatAuto ) this.scaleFormat = Default.FormatSecondSecond; tempStep = Math.Ceiling( tempStep * XDate.SecondsPerDay ); // make sure the second step size is 1, 5, 15, or 30 seconds if ( tempStep > 15.0 ) tempStep = 30.0; else if ( tempStep > 5.0 ) tempStep = 15.0; else if ( tempStep > 1.0 ) tempStep = 5.0; else if ( tempStep < 1.0 ) tempStep = 1.0; if ( minorStepAuto ) { minorUnit = DateUnit.Second; minorStep = 0.25; } } return tempStep; }
public Task<LocalDate> RollDate(DateTime date, int daycount, DateUnit rollType, BusinessDayConvention convention, string calendar) { return Carbon.GetInstance() .GetCarbonClientInstance() .RollDateAsync(date.ToNodaLocalDate(), daycount, rollType, convention, calendar); }
/// <summary> /// Copy Constructor. Create a new <see cref="Scale" /> object based on the specified /// existing one. /// </summary> /// <param name="rhs">The <see cref="Scale" /> object to be copied.</param> /// <param name="owner">The <see cref="Axis" /> object that will own the /// new instance of <see cref="Scale" /></param> public Scale( Scale rhs, Axis owner ) { _ownerAxis = owner; _min = rhs._min; _max = rhs._max; _majorStep = rhs._majorStep; _minorStep = rhs._minorStep; _exponent = rhs._exponent; _baseTic = rhs._baseTic; _minAuto = rhs._minAuto; _maxAuto = rhs._maxAuto; _majorStepAuto = rhs._majorStepAuto; _minorStepAuto = rhs._minorStepAuto; _magAuto = rhs._magAuto; _formatAuto = rhs._formatAuto; _minGrace = rhs._minGrace; _maxGrace = rhs._maxGrace; _mag = rhs._mag; _isUseTenPower = rhs._isUseTenPower; _isReverse = rhs._isReverse; _isPreventLabelOverlap = rhs._isPreventLabelOverlap; _isVisible = rhs._isVisible; _isSkipFirstLabel = rhs._isSkipFirstLabel; _isSkipLastLabel = rhs._isSkipLastLabel; _isSkipCrossLabel = rhs._isSkipCrossLabel; _majorUnit = rhs._majorUnit; _minorUnit = rhs._minorUnit; _format = rhs._format; _isLabelsInside = rhs._isLabelsInside; _align = rhs._align; _alignH = rhs._alignH; _fontSpec = (FontSpec) rhs._fontSpec.Clone(); _labelGap = rhs._labelGap; if ( rhs._textLabels != null ) _textLabels = (string[])rhs._textLabels.Clone(); else _textLabels = null; }
public static DateTime RollDate(CarbonClient client_, DateTime date_, int units_, DateUnit unit_, BusinessDayConvention conv_, string calendar_) { var key = getDateKey(date_, units_, unit_, conv_, calendar_); if (_dateCache.ContainsKey(key)) return _dateCache[key]; var date = client_.RollDateAsync( date: DateConversions.ToNodaLocalDate(date_.Date), count: units_, unit: unit_, convention: conv_, calendar: calendar_).Result; _dateCache[key] = date.ToDateTime(); return _dateCache[key]; }
/// <summary> /// Initializes a new instance of the <see cref="ScaleState"/> class. /// The Copy Constructor /// </summary> /// <param name="rhs"> /// The <see cref="ScaleState"/> object from which to copy /// </param> public ScaleState(ScaleState rhs) { this._min = rhs._min; this._majorStep = rhs._majorStep; this._minorStep = rhs._minorStep; this._max = rhs._max; this._majorUnit = rhs._majorUnit; this._minorUnit = rhs._minorUnit; this._format = rhs._format; this._mag = rhs._mag; this._minAuto = rhs._minAuto; this._majorStepAuto = rhs._majorStepAuto; this._minorStepAuto = rhs._minorStepAuto; this._maxAuto = rhs._maxAuto; this._formatAuto = rhs._formatAuto; this._magAuto = rhs._magAuto; }
public static DateTime GetDateForward(DateTime asOf_, int unitsForward_ = 2, DateUnit du_=DateUnit.Bd, string holidayCalendar_="EUTA") { lock (typeof(CarbonHistoricRetriever)) { var moniker = string.Format("{0}_{1}_{2}_{3}", asOf_, unitsForward_, du_, holidayCalendar_); if (_settleDAteCache.ContainsKey(moniker)) return _settleDAteCache[moniker]; _settleDAteCache[moniker] = DateConversions.ToDateTime(CarbonSubscriber.GetInstance().GetCarbonClientInstance().RollDateAsync( DateConversions.ToNodaLocalDate(asOf_), unitsForward_, du_, Symmetry.Carbon.Model.BusinessDayConvention.Following, holidayCalendar_).Result); return _settleDAteCache[moniker]; } }
private static string getDateKey(DateTime date_, int units_, DateUnit unit_, BusinessDayConvention conv_, string calendar_) { return string.Format("{0}_{1}_{2}_{3}_{4}", date_.ToString("ddMMyyyy"), units_, unit_, conv_, calendar_); }
/// <summary> /// Constructor for deserializing objects /// </summary> /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data /// </param> /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data /// </param> protected Scale( SerializationInfo info, StreamingContext context ) { // The schema value is just a file version parameter. You can use it to make future versions // backwards compatible as new member variables are added to classes int sch = info.GetInt32( "schema" ); _min = info.GetDouble( "min" ); _max = info.GetDouble( "max" ); _majorStep = info.GetDouble( "majorStep" ); _minorStep = info.GetDouble( "minorStep" ); _exponent = info.GetDouble( "exponent" ); _baseTic = info.GetDouble( "baseTic" ); _minAuto = info.GetBoolean( "minAuto" ); _maxAuto = info.GetBoolean( "maxAuto" ); _majorStepAuto = info.GetBoolean( "majorStepAuto" ); _minorStepAuto = info.GetBoolean( "minorStepAuto" ); _magAuto = info.GetBoolean( "magAuto" ); _formatAuto = info.GetBoolean( "formatAuto" ); _minGrace = info.GetDouble( "minGrace" ); _maxGrace = info.GetDouble( "maxGrace" ); _mag = info.GetInt32( "mag" ); _isReverse = info.GetBoolean( "isReverse" ); _isPreventLabelOverlap = info.GetBoolean( "isPreventLabelOverlap" ); _isUseTenPower = info.GetBoolean( "isUseTenPower" ); _isVisible = true; _isVisible = info.GetBoolean( "isVisible" ); _isSkipFirstLabel = info.GetBoolean( "isSkipFirstLabel" ); _isSkipLastLabel = info.GetBoolean( "isSkipLastLabel" ); _isSkipCrossLabel = info.GetBoolean( "isSkipCrossLabel" ); _textLabels = (string[]) info.GetValue( "textLabels", typeof(string[]) ); _format = info.GetString( "format" ); _majorUnit = (DateUnit) info.GetValue( "majorUnit", typeof(DateUnit) ); _minorUnit = (DateUnit) info.GetValue( "minorUnit", typeof(DateUnit) ); _isLabelsInside = info.GetBoolean( "isLabelsInside" ); _align = (AlignP)info.GetValue( "align", typeof( AlignP ) ); if ( schema >= 11 ) _alignH = (AlignH)info.GetValue( "alignH", typeof( AlignH ) ); _fontSpec = (FontSpec)info.GetValue( "fontSpec", typeof( FontSpec ) ); _labelGap = info.GetSingle( "labelGap" ); }
public DateFilter() { this.DateComparision = Nomad.Commons.DateComparision.Ignore; this.NotOlderThan = 1; this.DateMeasure = DateUnit.Day; }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="ScaleState"/> object from which to copy</param> public ScaleState( ScaleState rhs ) { _min = rhs._min; _majorStep = rhs._majorStep; _minorStep = rhs._minorStep; _max = rhs._max; _majorUnit = rhs._majorUnit; _minorUnit = rhs._minorUnit; _format = rhs._format; _mag = rhs._mag; _minAuto = rhs._minAuto; _majorStepAuto = rhs._majorStepAuto; _minorStepAuto = rhs._minorStepAuto; _maxAuto = rhs._maxAuto; _formatAuto = rhs._formatAuto; _magAuto = rhs._magAuto; }
/// <summary> /// Internal routine to calculate a multiplier to the selected unit back to days. /// </summary> /// <param name="unit">The unit type for which the multiplier is to be /// calculated</param> /// <returns> /// This is ratio of days/selected unit /// </returns> private double GetUnitMultiple( DateUnit unit ) { switch ( unit ) { case DateUnit.Year: default: return 365.0; case DateUnit.Month: return 30.0; case DateUnit.Day: return 1.0; case DateUnit.Hour: return 1.0 / XDate.HoursPerDay; case DateUnit.Minute: return 1.0 / XDate.MinutesPerDay; case DateUnit.Second: return 1.0 / XDate.SecondsPerDay; case DateUnit.Millisecond: return 1.0 / XDate.MillisecondsPerDay; } }
private static string getKey(DateTime date_, int units_, DateUnit unit_, BusinessDayConvention convention_, string otCalendar_) { return string.Format("{0}_{1}_{2}_{3}_{4}", date_, units_, unit_, convention_, otCalendar_); }
/// <summary> /// Default constructor for <see cref="Axis"/> that sets all axis properties /// to default values as defined in the <see cref="Default"/> class. /// </summary> public Axis() { this.min = 0.0; this.max = 1.0; this.step = 0.1; this.minorStep = 0.1; this.minGrace = Default.MinGrace; this.maxGrace = Default.MaxGrace; this.minAuto = true; this.maxAuto = true; this.stepAuto = true; this.minorStepAuto = true; this.numDecAuto = true; this.scaleMagAuto = true; this.scaleFormatAuto = true; this.numDec = 0; this.scaleMag = 0; this.ticSize = Default.TicSize; this.minorTicSize = Default.MinorTicSize; this.gridDashOn = Default.GridDashOn; this.gridDashOff = Default.GridDashOff; this.gridPenWidth = Default.GridPenWidth; this.minorGridDashOn = Default.MinorGridDashOn; this.minorGridDashOff = Default.MinorGridDashOff; this.minorGridPenWidth = Default.MinorGridPenWidth; this.minSpace = Default.MinSpace; this.isVisible = true; this.isShowTitle = Default.IsShowTitle; this.isShowGrid = Default.IsShowGrid; this.isShowMinorGrid = Default.IsShowMinorGrid; this.isReverse = Default.IsReverse; this.isOmitMag = false; this.isTic = Default.IsTic; this.isInsideTic = Default.IsInsideTic; this.isOppositeTic = Default.IsOppositeTic; this.isMinorTic = Default.IsMinorTic; this.isMinorInsideTic = Default.IsMinorInsideTic; this.isMinorOppositeTic = Default.IsMinorOppositeTic; this.isTicsBetweenLabels = false; this.isUseTenPower = true; this.type = Default.Type; this.title = ""; this.TextLabels = null; this.scaleFormat = null; this.scaleAlign = Default.ScaleAlign; this.majorUnit = DateUnit.Year; this.minorUnit = DateUnit.Year; this.ticPenWidth = Default.TicPenWidth; this.color = Default.Color; this.gridColor = Default.GridColor; this.minorGridColor = Default.MinorGridColor; this.titleFontSpec = new FontSpec( Default.TitleFontFamily, Default.TitleFontSize, Default.TitleFontColor, Default.TitleFontBold, Default.TitleFontUnderline, Default.TitleFontItalic, Default.TitleFillColor, Default.TitleFillBrush, Default.TitleFillType ); this.titleFontSpec.Border.IsVisible = false; this.scaleFontSpec = new FontSpec( Default.ScaleFontFamily, Default.ScaleFontSize, Default.ScaleFontColor, Default.ScaleFontBold, Default.ScaleFontUnderline, Default.ScaleFontItalic, Default.ScaleFillColor, Default.ScaleFillBrush, Default.ScaleFillType ); this.scaleFontSpec.Border.IsVisible = false; }
/// <summary> /// The Copy Constructor. /// </summary> /// <param name="rhs">The Axis object from which to copy</param> public Axis( Axis rhs ) { min = rhs.Min; max = rhs.Max; step = rhs.Step; minorStep = rhs.MinorStep; minAuto = rhs.MinAuto; maxAuto = rhs.MaxAuto; stepAuto = rhs.StepAuto; minorStepAuto = rhs.MinorStepAuto; numDecAuto = rhs.NumDecAuto; scaleMagAuto = rhs.ScaleMagAuto; scaleFormatAuto = rhs.ScaleFormatAuto; minGrace = rhs.MinGrace; maxGrace = rhs.MaxGrace; numDec = rhs.numDec; scaleMag = rhs.scaleMag; isVisible = rhs.IsVisible; isShowTitle = rhs.IsShowTitle; isShowGrid = rhs.IsShowGrid; isShowMinorGrid = rhs.IsShowMinorGrid; isZeroLine = rhs.IsZeroLine; isTic = rhs.IsTic; isInsideTic = rhs.IsInsideTic; isOppositeTic = rhs.IsOppositeTic; isMinorTic = rhs.IsMinorTic; isMinorInsideTic = rhs.IsMinorInsideTic; isMinorOppositeTic = rhs.IsMinorOppositeTic; isTicsBetweenLabels = rhs.IsTicsBetweenLabels; isUseTenPower = rhs.IsUseTenPower; isReverse = rhs.IsReverse; isOmitMag = rhs.IsOmitMag; title = rhs.Title; type = rhs.Type; majorUnit = rhs.MajorUnit; minorUnit = rhs.MinorUnit; if ( rhs.TextLabels != null ) TextLabels = (string[]) rhs.TextLabels.Clone(); else TextLabels = null; scaleFormat = rhs.scaleFormat; scaleAlign = rhs.scaleAlign; titleFontSpec = (FontSpec) rhs.TitleFontSpec.Clone(); scaleFontSpec = (FontSpec) rhs.ScaleFontSpec.Clone(); ticPenWidth = rhs.TicPenWidth; ticSize = rhs.TicSize; minorTicSize = rhs.MinorTicSize; gridDashOn = rhs.GridDashOn; gridDashOff = rhs.GridDashOff; gridPenWidth = rhs.GridPenWidth; minorGridDashOn = rhs.MinorGridDashOn; minorGridDashOff = rhs.MinorGridDashOff; minorGridPenWidth = rhs.MinorGridPenWidth; minSpace = rhs.MinSpace; color = rhs.Color; gridColor = rhs.GridColor; minorGridColor = rhs.MinorGridColor; }