public static bool Equal(this DateTime lhs, DateTime rhs, DateTimeUnit unit) { if (unit.ContainsAll(DateTimeUnit.Year)) { if (lhs.Year != rhs.Year) { return false; } } if (unit.ContainsAll(DateTimeUnit.Month)) { if (lhs.Month != rhs.Month) { return false; } } if (unit.ContainsAll(DateTimeUnit.Day)) { if (lhs.Day != rhs.Day) { return false; } } if (unit.ContainsAll(DateTimeUnit.Hour)) { if (lhs.Hour != rhs.Hour) { return false; } } if (unit.ContainsAll(DateTimeUnit.Minute)) { if (lhs.Minute != rhs.Minute) { return false; } } if (unit.ContainsAll(DateTimeUnit.Second)) { if (lhs.Second != rhs.Second) { return false; } } if (unit.ContainsAll(DateTimeUnit.Millisecond)) { if (lhs.Millisecond != rhs.Millisecond) { return false; } } return true; }
internal static void ValidateRelativeDatimeValidator(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType) { if ((((lowerBound != 0) && (lowerUnit == DateTimeUnit.None)) && (lowerBoundType != RangeBoundaryType.Ignore)) || (((upperBound != 0) && (upperUnit == DateTimeUnit.None)) && (upperBoundType != RangeBoundaryType.Ignore))) { throw new ArgumentException(Resources.RelativeDateTimeValidatorNotValidDateTimeUnit); } }
public DateTimeAdd(string TableName, object Object, ValueObjectType ObjectType, DateTimeUnit unit, Int64 interval) { this.TableName = TableName; this.Object = Object; this.ObjectType = ObjectType; this.Unit = unit; this.Interval = interval; }
public static IEnumerable<DateTime> Next(this DateTime date, DateTimeUnit unit, int count) { DateTime result = date; for (int i = 0; i < count; i++) { result = result.Add(unit.ToTimeSpan()); yield return result; } }
public RelativeDateTimeValidatorAttribute(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType) { ValidatorArgumentsValidatorHelper.ValidateRelativeDatimeValidator(lowerBound, lowerUnit, lowerBoundType, upperBound, upperUnit, upperBoundType); this.lowerBound = lowerBound; this.lowerUnit = lowerUnit; this.lowerBoundType = lowerBoundType; this.upperBound = upperBound; this.upperUnit = upperUnit; this.upperBoundType = upperBoundType; }
/// <summary> /// /// </summary> /// <param name="bound"></param> /// <param name="unit"></param> /// <param name="referenceDateTime"></param> /// <returns></returns> public DateTime GenerateBoundDateTime(int bound, DateTimeUnit unit, DateTime referenceDateTime) { DateTime result; switch (unit) { case DateTimeUnit.Day: result = referenceDateTime.AddDays(bound); break; case DateTimeUnit.Hour: result = referenceDateTime.AddHours(bound); break; case DateTimeUnit.Minute: result = referenceDateTime.AddMinutes(bound); break; case DateTimeUnit.Month: result = referenceDateTime.AddMonths(bound); break; case DateTimeUnit.Second: result = referenceDateTime.AddSeconds(bound); break; case DateTimeUnit.Year: result = referenceDateTime.AddYears(bound); break; default: result = referenceDateTime; break; } return result; }
public DateTime GenerateBoundDateTime(int bound, DateTimeUnit unit, DateTime referenceDateTime) { DateTime result; switch (unit) { case DateTimeUnit.Day: result = referenceDateTime.AddDays(bound); break; case DateTimeUnit.Hour: result = referenceDateTime.AddHours(bound); break; case DateTimeUnit.Minute: result = referenceDateTime.AddMinutes(bound); break; case DateTimeUnit.Month: result = referenceDateTime.AddMonths(bound); break; case DateTimeUnit.Second: result = referenceDateTime.AddSeconds(bound); break; case DateTimeUnit.Year: result = referenceDateTime.AddYears(bound); break; default: result = referenceDateTime; break; } return(result); }
public RelativeDateTimeValidatorOperation( string keyToValidate, string resultKey, int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundaryType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundaryType, bool negated) : base(keyToValidate, resultKey) { Validator = new RelativeDateTimeValidator( lowerBound, lowerUnit, lowerBoundaryType, upperBound, upperUnit, upperBoundaryType, string.Empty, negated ) { Tag = keyToValidate }; }
public void AddDateTime() { string unit = "S"; DateTimeUnit second = DateTimeHelper.GetDateTimeUnit(unit); DateTime dt = new DateTime(1981, 11, 6); Console.WriteLine("Original value: " + dt.ToString()); DateTime dt2007 = DateTimeHelper.AddDateTime(dt, DateTimeUnit.Year, 26); Console.WriteLine("New value: " + dt2007.ToString()); Assert.AreEqual(2007, dt2007.Year); DateTime dt20 = DateTimeHelper.AddDateTime(dt, DateTimeUnit.Hour, 20); Console.WriteLine("New value: " + dt20.ToString()); Assert.AreEqual(20, dt20.Hour); DateTime dt1127 = DateTimeHelper.AddDateTime(dt, DateTimeUnit.Week, 3); Console.WriteLine("New value: " + dt1127.ToString()); Assert.AreEqual(27, dt1127.Day); }
internal DateTime GenerateBoundDateTime(int bound, DateTimeUnit unit, DateTime referenceDateTime) { switch (unit) { case DateTimeUnit.Second: return referenceDateTime.AddSeconds((double) bound); case DateTimeUnit.Minute: return referenceDateTime.AddMinutes((double) bound); case DateTimeUnit.Hour: return referenceDateTime.AddHours((double) bound); case DateTimeUnit.Day: return referenceDateTime.AddDays((double) bound); case DateTimeUnit.Month: return referenceDateTime.AddMonths(bound); case DateTimeUnit.Year: return referenceDateTime.AddYears(bound); } return referenceDateTime; }
internal DateTime GenerateBoundDateTime(int bound, DateTimeUnit unit, DateTime referenceDateTime) { switch (unit) { case DateTimeUnit.Second: return(referenceDateTime.AddSeconds((double)bound)); case DateTimeUnit.Minute: return(referenceDateTime.AddMinutes((double)bound)); case DateTimeUnit.Hour: return(referenceDateTime.AddHours((double)bound)); case DateTimeUnit.Day: return(referenceDateTime.AddDays((double)bound)); case DateTimeUnit.Month: return(referenceDateTime.AddMonths(bound)); case DateTimeUnit.Year: return(referenceDateTime.AddYears(bound)); } return(referenceDateTime); }
public static DateTimeAdd DateTimeAdd(IPhrase phrase, DateTimeUnit unit, string addColumnName) { return new DateTimeAdd(phrase, unit, addColumnName); }
public static DateTimeAdd DateTimeAdd(string columnName, DateTimeUnit unit, Int64 interval) { return new DateTimeAdd(columnName, unit, interval); }
public DateTimeAdd(object value, ValueObjectType valueType, DateTimeUnit unit, string addColumnName) { this.Value1 = new ValueWrapper(value, valueType); this.Unit = unit; this.Value2 = new ValueWrapper(addColumnName); }
internal static void ValidateRelativeDatimeValidator(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType) { if ((((lowerBound != 0) && (lowerUnit == DateTimeUnit.None)) && (lowerBoundType != RangeBoundaryType.Ignore)) || (((upperBound != 0) && (upperUnit == DateTimeUnit.None)) && (upperBoundType != RangeBoundaryType.Ignore))) { throw new ArgumentException(Resources.RelativeDateTimeValidatorNotValidDateTimeUnit); } }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidator"/>.</para> /// </summary> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param> /// <param name="messageTemplate">The message template to use when logging results.</param> public RelativeDateTimeValidator(int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType, string messageTemplate) : this(0, DateTimeUnit.None, RangeBoundaryType.Ignore, upperBound, upperUnit, upperBoundType, messageTemplate) { }
public void GetDateTimeUnitInvalidUnit() { // unit string is invalid. string unit = "dday"; DateTimeUnit day = DateTimeHelper.GetDateTimeUnit(unit); }
public DateRange(DateTimeUnit unit) : this(DateTime.MinValue, DateTime.MaxValue, unit) { }
public DateRange(DateTime entry, DateTimeUnit unit) : this(entry, entry, unit) { }
public DateTimeAdd(string columnName, DateTimeUnit unit, string addColumnName) : this(null, columnName, unit, addColumnName) { }
public DateTimeAdd(IPhrase phrase, DateTimeUnit unit, string addColumnName) : this(phrase, ValueObjectType.Value, unit, addColumnName) { }
public DateTimeAdd(IPhrase phrase, DateTimeUnit unit, Int64 interval) : this(phrase, ValueObjectType.Value, unit, interval) { }
public DateTimeAdd(string columnName, DateTimeUnit unit, Int64 interval) : this(null, columnName, unit, interval) { }
public DateTimeAdd(string tableName, string columnName, DateTimeUnit unit, string addColumnName) { this.Value1 = new ValueWrapper(tableName, columnName); this.Unit = unit; this.Value2 = new ValueWrapper(addColumnName); }
public DateTimeAdd(object value, ValueObjectType valueType, DateTimeUnit unit, Int64 interval) { this.Value1 = new ValueWrapper(value, valueType); this.Unit = unit; this.Value2 = new ValueWrapper(interval, ValueObjectType.Value); }
public DateRange([NotNull] IReadOnlyRange <DateTime> range, DateTimeUnit unit) : this(range.Minimum, range.Maximum, unit) { }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidator"/>.</para> /// </summary> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> /// <param name="messageTemplate">The message template to use when logging results.</param> /// <param name="negated">True if the validator must negate the result of the validation.</param> public RelativeDateTimeValidator(int upperBound, DateTimeUnit upperUnit, string messageTemplate, bool negated) : this(0, DateTimeUnit.None, RangeBoundaryType.Ignore, upperBound, upperUnit, RangeBoundaryType.Inclusive, messageTemplate, negated) { }
public DateRangeLister([NotNull] LambdaRange <DateTime> range, DateTimeUnit unit) : this(range.Minimum, range.Maximum, unit) { }
internal static void ValidateRelativeDatimeValidator(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType) { if (lowerBound == 0 || lowerUnit != 0 || lowerBoundType == RangeBoundaryType.Ignore) { if (upperBound == 0) { return; } if (upperUnit != 0) { return; } if (upperBoundType == RangeBoundaryType.Ignore) { return; } } throw new ArgumentException(Resources.RelativeDateTimeValidatorNotValidDateTimeUnit); }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidatorAttribute"/>.</para> /// </summary> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param> public RelativeDateTimeValidatorAttribute(int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType) : this(0, DateTimeUnit.None, RangeBoundaryType.Ignore, upperBound, upperUnit, upperBoundType) { }
public DateRange(DateTime?start, DateTimeUnit unit) : this(start, null, unit) { }
public DateTimeAdd(string tableName, string columnName, DateTimeUnit unit, Int64 interval) { this.Value1 = new ValueWrapper(tableName, columnName); this.Unit = unit; this.Value2 = new ValueWrapper(interval, ValueObjectType.Value); }
public DateRangeLister(DateTime minimum, DateTime maximum, DateTimeUnit unit) : base(minimum, maximum) { switch (unit) { case DateTimeUnit.Year: _count = (int)Maximum.Years(Minimum); _getNextValue = () => { if (Index < 0) { return(Minimum); } if (Index >= _count - 1) { return(null); } if (Minimum.TryAddYears(Index + 1, out DateTime result)) { return(result); } return(null); }; break; case DateTimeUnit.Month: _count = (int)Maximum.Months(Minimum).NotAbove(int.MaxValue); _getNextValue = () => { if (Index < 0) { return(Minimum); } if (Index >= _count - 1) { return(null); } if (Minimum.TryAddMonths(Index + 1, out DateTime result)) { return(result); } return(null); }; break; case DateTimeUnit.Hour: _count = (int)Maximum.Hours(Minimum).NotAbove(int.MaxValue); _getNextValue = () => { if (Index < 0) { return(Minimum); } if (Index >= _count - 1) { return(null); } if (Minimum.TryAddHours(Index + 1, out DateTime result)) { return(result); } return(null); }; break; case DateTimeUnit.Minute: _count = (int)Maximum.Minutes(Minimum).NotAbove(int.MaxValue); _getNextValue = () => { if (Index < 0) { return(Minimum); } if (Index >= _count - 1) { return(null); } if (Minimum.TryAddMinutes(Index + 1, out DateTime result)) { return(result); } return(null); }; break; case DateTimeUnit.Second: _count = (int)Maximum.Seconds(Minimum).NotAbove(int.MaxValue); _getNextValue = () => { if (Index < 0) { return(Minimum); } if (Index >= _count - 1) { return(null); } if (Minimum.TryAddSeconds(Index + 1, out DateTime result)) { return(result); } return(null); }; break; case DateTimeUnit.Millisecond: _count = (int)Maximum.Milliseconds(Minimum).NotAbove(int.MaxValue); _getNextValue = () => { if (Index < 0) { return(Minimum); } if (Index >= _count - 1) { return(null); } if (Minimum.TryAddMilliseconds(Index + 1, out DateTime result)) { return(result); } return(null); }; break; default: // default to add day _count = (int)Maximum.Days(Minimum).NotAbove(int.MaxValue); _getNextValue = () => { if (Index < 0) { return(Minimum); } if (Index >= _count - 1) { return(null); } if (Minimum.TryAddDays(Index + 1, out DateTime result)) { return(result); } return(null); }; break; } }
/// <summary> /// Creates an instance of <see cref="RelativeDateTimeValidatorNode"/> based on runtime configuration data. /// </summary> /// <param name="validatorData">The corresponding runtime configuration data.</param> public RelativeDateTimeValidatorNode(RelativeDateTimeValidatorData validatorData) : base(validatorData) { this.lowerUnit = validatorData.LowerUnit; this.upperUnit = validatorData.UpperUnit; }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidatorAttribute"/>.</para> /// </summary> /// <param name="lowerBound">The lower bound.</param> /// <param name="lowerUnit">The lower bound unit of time.</param> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> public RelativeDateTimeValidatorAttribute(int lowerBound, DateTimeUnit lowerUnit, int upperBound, DateTimeUnit upperUnit) : this(lowerBound, lowerUnit, RangeBoundaryType.Inclusive, upperBound, upperUnit, RangeBoundaryType.Inclusive) { }
public RelativeDateTimeValidatorAttribute(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType) { ValidatorArgumentsValidatorHelper.ValidateRelativeDatimeValidator(lowerBound, lowerUnit, lowerBoundType, upperBound, upperUnit, upperBoundType); this.lowerBound = lowerBound; this.lowerUnit = lowerUnit; this.lowerBoundType = lowerBoundType; this.upperBound = upperBound; this.upperUnit = upperUnit; this.upperBoundType = upperBoundType; }
public RelativeDateTimeValidator(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType, string messageTemplate, bool negated) : base(messageTemplate, (string)null, negated) { ValidatorArgumentsValidatorHelper.ValidateRelativeDatimeValidator(lowerBound, lowerUnit, lowerBoundType, upperBound, upperUnit, upperBoundType); this.lowerBound = lowerBound; this.lowerUnit = lowerUnit; this.upperBound = upperBound; this.upperUnit = upperUnit; this.generator = new RelativeDateTimeGenerator(); DateTime now = DateTime.Now; DateTime dateTime = this.generator.GenerateBoundDateTime(lowerBound, lowerUnit, now); DateTime dateTime2 = this.generator.GenerateBoundDateTime(upperBound, upperUnit, now); this.rangeChecker = new RangeChecker <DateTime>(dateTime, lowerBoundType, dateTime2, upperBoundType); }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidatorAttribute"/>.</para> /// </summary> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param> public RelativeDateTimeValidatorAttribute(int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType) : this(0, DateTimeUnit.None, RangeBoundaryType.Ignore, upperBound, upperUnit, upperBoundType) { }
public static DateTimeAdd DateTimeAdd(object value, ValueObjectType valueType, DateTimeUnit unit, Int64 interval) { return new DateTimeAdd(value, valueType, unit, interval); }
public virtual bool Equal(DateTime lhs, DateTime rhs, DateTimeUnit unit) { }
public static DateTimeAdd DateTimeAdd(IPhrase phrase, DateTimeUnit unit, Int64 interval) { return new DateTimeAdd(phrase, unit, interval); }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidator"/>.</para> /// </summary> /// <param name="messageTemplate">The message template to use when logging results.</param> /// <param name="lowerBound">The lower bound.</param> /// <param name="lowerUnit">The lower bound unit of time.</param> /// <param name="lowerBoundType">The indication of how to perform the lower bound check.</param> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param> public RelativeDateTimeValidator(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType, string messageTemplate) : this(lowerBound, lowerUnit, lowerBoundType, upperBound, upperUnit, upperBoundType, messageTemplate, false) { }
public static DateTimeAdd DateTimeAdd(string columnName, DateTimeUnit unit, string addColumnName) { return new DateTimeAdd(columnName, unit, addColumnName); }
public virtual DateTime Truncate(DateTime instance, DateTimeUnit unit) { }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidator"/>.</para> /// </summary> /// <param name="lowerBound">The lower bound.</param> /// <param name="lowerUnit">The lower bound unit of time.</param> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> /// <param name="negated">True if the validator must negate the result of the validation.</param> public RelativeDateTimeValidator(int lowerBound, DateTimeUnit lowerUnit, int upperBound, DateTimeUnit upperUnit, bool negated) : this(lowerBound, lowerUnit, RangeBoundaryType.Inclusive, upperBound, upperUnit, RangeBoundaryType.Inclusive, negated) { }
private void DrawCharts() { long ttSecStart = this.TTSecEnd - this.TTSecStep * (Consts.PLOT_NUM - 1); this.MaChart.Series.Clear(); this.MaChart.Legends.Clear(); this.MaChart.ChartAreas.Clear(); double maYMin = double.MaxValue; double maYMax = double.MinValue; // Low { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = Color.LightGray; srs.BorderWidth = 2; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double y = ChartSrvc.I.Ttc.GetPrice(ttSec).Low; maYMin = Math.Min(maYMin, y); maYMax = Math.Max(maYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.MaChart.Series.Add(srs); } // Hig { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = Color.LightGray; srs.BorderWidth = 2; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double y = ChartSrvc.I.Ttc.GetPrice(ttSec).Hig; maYMin = Math.Min(maYMin, y); maYMax = Math.Max(maYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.MaChart.Series.Add(srs); } // Mid { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = Color.Green; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double y = ChartSrvc.I.Ttc.GetPrice(ttSec).Mid; maYMin = Math.Min(maYMin, y); maYMax = Math.Max(maYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.MaChart.Series.Add(srs); } for (int maIndex = 0; maIndex < ChartSrvc.I.Macs.Length; maIndex++) { ChartSrvc.MacInfo mac = ChartSrvc.I.Macs[maIndex]; Color maColor = Consts.MaColors[maIndex]; // ma { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = maColor; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double y = mac.Mac.GetPrice(ttSec); maYMin = Math.Min(maYMin, y); maYMax = Math.Max(maYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.MaChart.Series.Add(srs); } } // ca { ChartArea ca = new ChartArea(); ca.AxisX.Minimum = ttSecStart / 86400.0; ca.AxisX.Maximum = this.TTSecEnd / 86400.0; ca.AxisY.Minimum = maYMin; ca.AxisY.Maximum = maYMax; { double q = (ca.AxisX.Maximum - ca.AxisX.Minimum) / 6.0; double x1 = ca.AxisX.Minimum; double x2 = ca.AxisX.Minimum + q * 2.0; double x3 = ca.AxisX.Minimum + q * 4.0; double x4 = ca.AxisX.Maximum; double xVal1 = ca.AxisX.Minimum + q * 1.0; double xVal2 = ca.AxisX.Minimum + q * 3.0; double xVal3 = ca.AxisX.Minimum + q * 5.0; #if true #if true long xSec1 = DoubleTools.ToLong(xVal1 * 86400.0); long xSec2 = DoubleTools.ToLong(xVal2 * 86400.0); long xSec3 = DoubleTools.ToLong(xVal3 * 86400.0); string xL1 = StringUtils.SecSpanToUIString(0); string xL2 = StringUtils.SecSpanToUIString(xSec2 - xSec1); string xL3 = StringUtils.SecSpanToUIString(xSec3 - xSec1); #else // old string xL1 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal1 * 86400.0))).ToString(); string xL2 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal2 * 86400.0))).ToString(); string xL3 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal3 * 86400.0))).ToString(); #endif ca.AxisX.CustomLabels.Add(new CustomLabel(x1, x2, xL1, 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x2, x3, xL2, 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x3, x4, xL3, 0, LabelMarkStyle.None, GridTickTypes.All)); #else // old ca.AxisX.CustomLabels.Add(new CustomLabel(x1, x2, xVal1.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x2, x3, xVal2.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x3, x4, xVal3.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); #endif } { double q = (ca.AxisY.Maximum - ca.AxisY.Minimum) / 6.0; double y1 = ca.AxisY.Minimum; double y2 = ca.AxisY.Minimum + q * 2.0; double y3 = ca.AxisY.Minimum + q * 4.0; double y4 = ca.AxisY.Maximum; double yVal1 = ca.AxisY.Minimum + q * 1.0; double yVal2 = ca.AxisY.Minimum + q * 3.0; double yVal3 = ca.AxisY.Minimum + q * 5.0; ca.AxisY.CustomLabels.Add(new CustomLabel(y1, y2, yVal1.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisY.CustomLabels.Add(new CustomLabel(y2, y3, yVal2.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisY.CustomLabels.Add(new CustomLabel(y3, y4, yVal3.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); } this.MaChart.ChartAreas.Add(ca); } this.DmaChart.Series.Clear(); this.DmaChart.Legends.Clear(); this.DmaChart.ChartAreas.Clear(); double dmaYMin = Consts.DMA_LOW_03; double dmaYMax = Consts.DMA_HIG_03; { Action <double, int, Color> drawHorizontallyLine = (y, width, color) => { double x1 = ttSecStart / 86400.0; double x2 = this.TTSecEnd / 86400.0; Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = color; srs.BorderWidth = width; srs.Points.AddXY(x1, y); srs.Points.AddXY(x2, y); this.DmaChart.Series.Add(srs); }; drawHorizontallyLine(Consts.DMA_HIG_03, 7, Color.LightBlue); drawHorizontallyLine(Consts.DMA_HIG_02, 5, Color.LightBlue); drawHorizontallyLine(Consts.DMA_HIG_01, 3, Color.LightBlue); drawHorizontallyLine(0.0, 3, Color.LightGray); drawHorizontallyLine(Consts.DMA_LOW_01, 3, Color.LightPink); drawHorizontallyLine(Consts.DMA_LOW_02, 5, Color.LightPink); drawHorizontallyLine(Consts.DMA_LOW_03, 7, Color.LightPink); } for (int maIndex = 0; maIndex < ChartSrvc.I.Macs.Length; maIndex++) { ChartSrvc.MacInfo mac = ChartSrvc.I.Macs[maIndex]; Color maColor = Consts.MaColors[maIndex]; // ma { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = maColor; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double prY = ChartSrvc.I.Ttc.GetPrice(ttSec).Mid; double maY = mac.Mac.GetPrice(ttSec); double y = (prY - maY) / maY; dmaYMin = Math.Min(dmaYMin, y); dmaYMax = Math.Max(dmaYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.DmaChart.Series.Add(srs); } } // ca { ChartArea ca = new ChartArea(); ca.AxisX.Minimum = ttSecStart / 86400.0; ca.AxisX.Maximum = this.TTSecEnd / 86400.0; ca.AxisY.Minimum = dmaYMin; ca.AxisY.Maximum = dmaYMax; { double q = (ca.AxisX.Maximum - ca.AxisX.Minimum) / 6.0; double x1 = ca.AxisX.Minimum; double x2 = ca.AxisX.Minimum + q * 2.0; double x3 = ca.AxisX.Minimum + q * 4.0; double x4 = ca.AxisX.Maximum; double xVal1 = ca.AxisX.Minimum + q * 1.0; double xVal2 = ca.AxisX.Minimum + q * 3.0; double xVal3 = ca.AxisX.Minimum + q * 5.0; #if true string xL1 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal1 * 86400.0))).ToString(); string xL2 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal2 * 86400.0))).ToString(); string xL3 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal3 * 86400.0))).ToString(); ca.AxisX.CustomLabels.Add(new CustomLabel(x1, x2, xL1, 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x2, x3, xL2, 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x3, x4, xL3, 0, LabelMarkStyle.None, GridTickTypes.All)); #else // old ca.AxisX.CustomLabels.Add(new CustomLabel(x1, x2, xVal1.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x2, x3, xVal2.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x3, x4, xVal3.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); #endif } { double q = (ca.AxisY.Maximum - ca.AxisY.Minimum) / 6.0; double y1 = ca.AxisY.Minimum; double y2 = ca.AxisY.Minimum + q * 2.0; double y3 = ca.AxisY.Minimum + q * 4.0; double y4 = ca.AxisY.Maximum; double yVal1 = ca.AxisY.Minimum + q * 1.0; double yVal2 = ca.AxisY.Minimum + q * 3.0; double yVal3 = ca.AxisY.Minimum + q * 5.0; ca.AxisY.CustomLabels.Add(new CustomLabel(y1, y2, yVal1.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisY.CustomLabels.Add(new CustomLabel(y2, y3, yVal2.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisY.CustomLabels.Add(new CustomLabel(y3, y4, yVal3.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); } this.DmaChart.ChartAreas.Add(ca); } { string text = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(ttSecStart)).ToString() + " ~ " + DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(this.TTSecEnd)).ToString() + ", Range: " + (this.TTSecEnd - ttSecStart) + " sec (" + ((this.TTSecEnd - ttSecStart) / 86400.0) + " days), Step: " + this.TTSecStep + " sec, MA: { " + string.Join(", ", ChartSrvc.I.Macs.Select(v => v.SecSpan + "s_" + (v.SecSpan / 86400.0).ToString("F3") + "d")) + " } MA_Step: " + this.MaStep + " sec"; if (this.South.Text != text) { this.South.Text = text; } } }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidatorAttribute"/>.</para> /// </summary> /// <param name="lowerBound">The lower bound.</param> /// <param name="lowerUnit">The lower bound unit of time.</param> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> public RelativeDateTimeValidatorAttribute(int lowerBound, DateTimeUnit lowerUnit, int upperBound, DateTimeUnit upperUnit) : this(lowerBound, lowerUnit, RangeBoundaryType.Inclusive, upperBound, upperUnit, RangeBoundaryType.Inclusive) { }
public DateTimeAdd(object Object, ValueObjectType ObjectType, DateTimeUnit unit, Int64 interval) : this(null, Object, ObjectType, unit, interval) { }
public static DateTime Truncate(this DateTime instance, DateTimeUnit unit) { var year = unit.ContainsAll(DateTimeUnit.Year) ? instance.Year : 1; var month = unit.ContainsAll(DateTimeUnit.Month) ? instance.Month : 1; var day = unit.ContainsAll(DateTimeUnit.Day) ? instance.Day : 1; var hour = unit.ContainsAll(DateTimeUnit.Hour) ? instance.Hour : 0; var minute = unit.ContainsAll(DateTimeUnit.Minute) ? instance.Minute : 0; var second = unit.ContainsAll(DateTimeUnit.Second) ? instance.Second : 0; var millisecond = unit.ContainsAll(DateTimeUnit.Millisecond) ? instance.Millisecond : 0; return new DateTime(year, month, day, hour, minute, second, millisecond, instance.Kind); }
public DateTimeAdd(string ColumnName, DateTimeUnit unit, Int64 interval) : this(null, ColumnName, ValueObjectType.ColumnName, unit, interval) { }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidator"/>.</para> /// </summary> /// <param name="negated">True if the validator must negate the result of the validation.</param> /// <param name="lowerBound">The lower bound.</param> /// <param name="lowerUnit">The lower bound unit of time.</param> /// <param name="lowerBoundType">The indication of how to perform the lower bound check.</param> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param> public RelativeDateTimeValidator(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType, int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType, bool negated) : this(lowerBound, lowerUnit, lowerBoundType, upperBound, upperUnit, upperBoundType, null, negated) { }
public virtual bool Equal(DateTime lhs, DateTime rhs, DateTimeUnit unit) { }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidator"/>.</para> /// </summary> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> public RelativeDateTimeValidator(int upperBound, DateTimeUnit upperUnit) : this(0, DateTimeUnit.None, RangeBoundaryType.Ignore, upperBound, upperUnit, RangeBoundaryType.Inclusive, false) { }
public virtual DateTime Truncate(DateTime instance, DateTimeUnit unit) { }
/// <summary> /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidator"/>.</para> /// </summary> /// <param name="upperBound">The upper bound</param> /// <param name="upperUnit">The upper bound unit of time.</param> /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param> /// <param name="negated">True if the validator must negate the result of the validation.</param> public RelativeDateTimeValidator(int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType, bool negated) : this(0, DateTimeUnit.None, RangeBoundaryType.Ignore, upperBound, upperUnit, upperBoundType, negated) { }
public void GetDateTimeUnitException() { // unit string is null or empty. string unit = string.Empty; DateTimeUnit dtu = DateTimeHelper.GetDateTimeUnit(unit); }
public static bool IsLessThan(this DateTime thisValue, DateTime destination, double limit, DateTimeUnit dateTimeUnit) { double n = DateTimeHelper.Limit(limit, dateTimeUnit) * -1; DateTimeUnit unit = n < 0.0D ? dateTimeUnit : DateTimeUnit.None; switch (unit) { case DateTimeUnit.None: return(thisValue < destination); case DateTimeUnit.Year: return(thisValue < destination.AddYears((int)n)); case DateTimeUnit.Month: return(thisValue < destination.AddMonths((int)n)); case DateTimeUnit.Day: return(thisValue < destination.AddDays(n)); case DateTimeUnit.Hour: return(thisValue < destination.AddHours(n)); case DateTimeUnit.Minute: return(thisValue < destination.AddMinutes(n)); case DateTimeUnit.Second: return(thisValue < destination.AddSeconds(n)); case DateTimeUnit.Millisecond: return(thisValue < destination.AddMilliseconds(n)); default: throw new ArgumentOutOfRangeException(nameof(dateTimeUnit)); } }
private void MainTimer_Tick(object sender, EventArgs e) { if (this.MTBusy.HasVisitor()) { return; } this.MTBusy.Enter(); try { if (this.XPressed) { this.XPressed = false; this.CloseWindow(); return; } // -- 3001 // ---- CondChanged if (this.CondChangedCount == 1) // Do Refresh { GrphCond cond = null; string statusText = this.Status.Text; bool statusTextErrorFlag = false; try { cond = this.GetGrphCond(); } catch (Exception ex) { statusText = ex.Message; statusTextErrorFlag = true; this.LastGrphCond = null; } if (cond != null && (this.LastGrphCond == null || this.LastGrphCond.IsSame(cond) == false)) // ? グラフ更新の必要あり { this.LastGrphCond = cond; // DrawGrph()が例外を投げたとき何度もDrawGrph()しないよう、先に更新する。 this.DrawGrph(cond); statusText = DateTimeUnit.FromDateTime(Ground.I.GrphData.GetPrice(Ground.I.GrphData.Start).DateTime) + " ~ " + DateTimeUnit.FromDateTime(Ground.I.GrphData.GetPrice(Ground.I.GrphData.End).DateTime) + ", Range: " + (Ground.I.GrphData.GetPrice(Ground.I.GrphData.End).TTSec - Ground.I.GrphData.GetPrice(Ground.I.GrphData.Start).TTSec) + " sec (" + ((Ground.I.GrphData.GetPrice(Ground.I.GrphData.End).TTSec - Ground.I.GrphData.GetPrice(Ground.I.GrphData.Start).TTSec) / 86400.0).ToString("F3") + " days), Step: " + Ground.I.GrphData.Step + " mins"; } if (this.Status.Text != statusText) { this.Status.Text = statusText; } Color statusTextForeColor = Consts.LABEL_FORE_COLOR; Color statusTextBackColor = Consts.LABEL_BACK_COLOR; if (statusTextErrorFlag) { statusTextForeColor = Color.White; statusTextBackColor = Color.Red; } if (this.Status.ForeColor != statusTextForeColor) { this.Status.ForeColor = statusTextForeColor; } if (this.Status.BackColor != statusTextBackColor) { this.Status.BackColor = statusTextBackColor; } } { string text = StringTools.Repeat("/", this.CondChangedCount); if (this.SubStatus.Text != text) { this.SubStatus.Text = text; } } if (0 < this.CondChangedCount) { this.CondChangedCount--; } // ---- } catch (Exception ex) { MessageDlgTools.Error(Program.APP_TITLE + " - Error @ Timer", ex); } finally { this.MTBusy.Leave(); this.MTCount++; } }