本文整理汇总了C#中System.DateTime.Proper方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.Proper方法的具体用法?C# DateTime.Proper怎么用?C# DateTime.Proper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.Proper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addTimeUnits
public static DateTime addTimeUnits(DateTime date, TimeframeSymbol timeframe, int units)
{
switch (timeframe)
{
case TimeframeSymbol.MN1:
return addTimeUnits_month(date, units);
case TimeframeSymbol.W1:
return addTimeUnits_weeks(date.Proper(timeframe), units);
case TimeframeSymbol.D1:
return addTimeUnits_days(date.Proper(timeframe), units);
case TimeframeSymbol.H4:
case TimeframeSymbol.H1:
case TimeframeSymbol.M30:
case TimeframeSymbol.M15:
case TimeframeSymbol.M5:
return addTimeUnits_shortPeriods(date.Proper(timeframe), timeframe, units);
}
return date;
}
示例2: proper_weeks_for_sundays_the_same_date_is_returned
public void proper_weeks_for_sundays_the_same_date_is_returned()
{
DateTime baseDate = new DateTime(2016, 4, 17);
Assert.AreEqual(baseDate, baseDate.Proper(TimeframeSymbol.W1));
}
示例3: proper_weeks_for_dayOfWeek_other_than_sunday_last_sunday_is_returned
public void proper_weeks_for_dayOfWeek_other_than_sunday_last_sunday_is_returned()
{
DateTime baseDate = new DateTime(2016, 4, 21);
Assert.AreEqual(new DateTime(2016, 4, 17), baseDate.Proper(TimeframeSymbol.W1));
}
示例4: proper_months_for_other_than_first_day_of_months_first_day_of_this_month_is_returned
public void proper_months_for_other_than_first_day_of_months_first_day_of_this_month_is_returned()
{
DateTime baseDate = new DateTime(2016, 8, 15);
Assert.AreEqual(new DateTime(2016, 8, 1), baseDate.Proper(TimeframeSymbol.MN1));
}
示例5: proper_months_for_first_day_of_months_the_same_day_is_returned
public void proper_months_for_first_day_of_months_the_same_day_is_returned()
{
DateTime baseDate = new DateTime(2016, 8, 1);
Assert.AreEqual(baseDate, baseDate.Proper(TimeframeSymbol.MN1));
}
示例6: proper_days_for_non_weekend_day_this_day_is_returned
public void proper_days_for_non_weekend_day_this_day_is_returned()
{
DateTime baseDate = new DateTime(2016, 4, 18);
Assert.AreEqual(baseDate, baseDate.Proper(TimeframeSymbol.D1));
}
示例7: proper_m5_for_time_between_full_hours_function_returns_earlier_full_hour
public void proper_m5_for_time_between_full_hours_function_returns_earlier_full_hour()
{
DateTime baseDate = new DateTime(2016, 8, 11, 15, 41, 31);
Assert.AreEqual(new DateTime(2016, 8, 11, 15, 40, 0), baseDate.Proper(TimeframeSymbol.M5));
}
示例8: countTimeUnits_shortPeriod
private static int countTimeUnits_shortPeriod(DateTime baseDate, DateTime comparedDate, TimeframeSymbol timeframe)
{
DateTime properBaseDate = baseDate.Proper(timeframe);
DateTime properComparedDate = comparedDate.Proper(timeframe);
TimeSpan span = getTimespan(timeframe);
int spanMinutes = span.Hours * 60 + span.Minutes;
long datesMinutesDifference = (properComparedDate - properBaseDate).Ticks / 600000000;
int result = (int) datesMinutesDifference / spanMinutes;
int excluded = countExcludedItems(baseDate, comparedDate, timeframe);
return result - countExcludedItems(baseDate, comparedDate, timeframe);
}
示例9: proper_m5_for_newYearEve_22__21_of_this_day_is_returned
public void proper_m5_for_newYearEve_22__21_of_this_day_is_returned()
{
DateTime baseDate = new DateTime(2015, 12, 31, 22, 0, 0);
Assert.AreEqual(new DateTime(2015, 12, 31, 21, 0, 0), baseDate.Proper(TimeframeSymbol.M5));
}
示例10: proper_m5_for_newYear_value_function_returns_last_valid_value_before
public void proper_m5_for_newYear_value_function_returns_last_valid_value_before()
{
DateTime baseDate = new DateTime(2016, 1, 1, 16, 0, 0);
Assert.AreEqual(new DateTime(2015, 12, 31, 21, 0, 0), baseDate.Proper(TimeframeSymbol.M5));
}
示例11: proper_m30_for_christmasEve_2130__21_of_this_day_is_returned
public void proper_m30_for_christmasEve_2130__21_of_this_day_is_returned()
{
DateTime baseDate = new DateTime(2015, 12, 24, 21, 30, 0);
Assert.AreEqual(new DateTime(2015, 12, 24, 21, 0, 0), baseDate.Proper(TimeframeSymbol.M30));
}
示例12: proper_days_for_weekend_new_year_friday_before_is_returned
public void proper_days_for_weekend_new_year_friday_before_is_returned()
{
DateTime baseDate = new DateTime(2017, 1, 1);
Assert.AreEqual(new DateTime(2016, 12, 30), baseDate.Proper(TimeframeSymbol.D1));
}
示例13: proper_days_for_sunday_friday_before_is_returned
public void proper_days_for_sunday_friday_before_is_returned()
{
DateTime baseDate = new DateTime(2016, 8, 14);
Assert.AreEqual(new DateTime(2016, 8, 12), baseDate.Proper(TimeframeSymbol.D1));
}
示例14: addTimeUnits_shortPeriods
private static DateTime addTimeUnits_shortPeriods(DateTime date, TimeframeSymbol timeframe, int units)
{
DateTime startDate = new DateTime(date.Ticks).Proper(timeframe);
TimeSpan span = (Math.Sign(units) == 1 ? getTimespan(timeframe) : getTimespan(timeframe).invert());
int sign = Math.Sign(units);
for(var i = 1; i <= Math.Abs(units); i++){
startDate = startDate.Add(span);
if (!startDate.isOpenMarketTime())
{
DateTime nextOpenMarketTime = startDate.ifNotOpenMarketGetNext();
DateTime proper = startDate.Proper(timeframe);
startDate = (sign > 0 ? startDate.ifNotOpenMarketGetNext() : startDate.Proper(timeframe));
}
}
return startDate;
}
示例15: proper_m5_for_weekendNewYear_value_function_returns_2355PM_last_friday_of_previous_year
public void proper_m5_for_weekendNewYear_value_function_returns_2355PM_last_friday_of_previous_year()
{
DateTime baseDate = new DateTime(2017, 1, 1, 12, 0, 0);
Assert.AreEqual(new DateTime(2016, 12, 30, 23, 55, 0), baseDate.Proper(TimeframeSymbol.M5));
}