本文整理汇总了C#中TimeUnit.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TimeUnit.ToString方法的具体用法?C# TimeUnit.ToString怎么用?C# TimeUnit.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeUnit
的用法示例。
在下文中一共展示了TimeUnit.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getUsers
public UsersResult getUsers(TimeUnit timeUnit, String start, int duration)
{
String url = REPORT_HOST_NAME + REPORT_USER_PATH
+ "?time_unit=" + timeUnit.ToString()
+ "&start=" + start + "&duration=" + duration;
String auth = Base64.getBase64Encode(this.appKey + ":" + this.masterSecret);
ResponseWrapper response = this.sendGet(url, auth, null);
return UsersResult.fromResponse(response);
}
示例2: GetResourceKey
/// <summary>
/// Generates Resource Keys accordning to convention.
/// </summary>
/// <param name="timeUnit">Time unit</param>
/// <param name="timeUnitTense">Is time unit in future or past</param>
/// <param name="count">Number of units, default is One.</param>
/// <returns>Resource key, like DateHumanize_SingleMinuteAgo</returns>
public static string GetResourceKey(TimeUnit timeUnit, Tense timeUnitTense, int count = 1)
{
ValidateRange(count);
if (count == 0)
return Now;
var singularity = count == 1 ? Single : Multiple;
var tense = timeUnitTense == Tense.Future ? FromNow : Ago;
var unit = timeUnit.ToString().ToQuantity(count, ShowQuantityAs.None);
return DateTimeFormat.FormatWith(singularity, unit, tense);
}
示例3: ScheduledReporter
/// <summary>
/// Creates a new <see cref="ScheduledReporter"/> instance
/// </summary>
/// <param name="registry">the <see cref="MetricRegistry"/> containing the metrics this reporter will report</param>
/// <param name="name">the reporter's name</param>
/// <param name="filter">the filter for which metrics to report</param>
/// <param name="rateUnit">a unit of time</param>
/// <param name="durationUnit">a unit of time</param>
protected ScheduledReporter(MetricRegistry registry,
string name,
MetricFilter filter,
TimeUnit rateUnit,
TimeUnit durationUnit)
{
this.registry = registry;
this.filter = filter;
this.rateFactor = rateUnit.ToSeconds(1);
this.rateUnit = calculateRateUnit(rateUnit);
this.durationFactor = 1.0 / durationUnit.ToNanos(1);
this.durationUnit = durationUnit.ToString().ToLowerInvariant();
}
示例4: AddTimeLength
/// <summary>
/// 增加时长。
/// </summary>
/// <param name="thisTime"></param>
/// <param name="timeUnit"></param>
/// <param name="timeLength"></param>
/// <returns></returns>
public static DateTime AddTimeLength(DateTime thisTime, TimeUnit timeUnit, int timeLength)
{
switch (timeUnit)
{
case TimeUnit.Hour:
return thisTime.AddHours(timeLength);
case TimeUnit.Minute:
return thisTime.AddMinutes(timeLength);
case TimeUnit.Second:
return thisTime.AddSeconds(timeLength);
default:
throw new Exception("无法识别时间单位:" + timeUnit.ToString());
}
}
示例5: EditDivisionWindow
public EditDivisionWindow(double timeValue,TimeUnit timeUnit)
{
InitializeComponent();
resultTimeUnit = timeUnit;
resultTimeValue = timeValue;
Text_TimeValue.Text = timeValue.ToString();
foreach (string typeName in Enum.GetNames(typeof(TimeUnit))) {
Combo_TimeUnit.Items.Add(typeName);
if (typeName == timeUnit.ToString()) {
Combo_TimeUnit.SelectedItem = typeName;
}
}
}
示例6: FillTimeRange
/// <summary>
/// 设置时段。
/// </summary>
/// <param name="thisTime"></param>
/// <param name="timeUnit"></param>
/// <param name="timeLength"></param>
public static void FillTimeRange(WorkingTimeRange timeRange, DateTime thisTime, TimeUnit timeUnit, int timeLength)
{
//取得当前时间所在时段的起始分钟数。
TimeSpan ts = thisTime - thisTime.Date;
//设置时段范围。
double count;
int startOffset;
switch (timeUnit)
{
case TimeUnit.Hour:
count = ts.TotalHours / timeLength;
startOffset = (int)count * timeLength;
timeRange.StartTime = thisTime.Date.AddHours(startOffset);
timeRange.EndTime = timeRange.StartTime.AddHours(timeLength);
break;
case TimeUnit.Minute:
count = ts.TotalMinutes / timeLength;
startOffset = (int)count * timeLength;
timeRange.StartTime = thisTime.Date.AddMinutes(startOffset);
timeRange.EndTime = timeRange.StartTime.AddMinutes(timeLength);
break;
case TimeUnit.Second:
count = ts.TotalSeconds / timeLength;
startOffset = (int)count * timeLength;
timeRange.StartTime = thisTime.Date.AddSeconds(startOffset);
timeRange.EndTime = timeRange.StartTime.AddSeconds(timeLength);
break;
default:
throw new Exception("无法识别时间单位:" + timeUnit.ToString());
}
}
示例7: calculateRateUnit
private string calculateRateUnit(TimeUnit unit)
{
string s = unit.ToString().ToLowerInvariant();
return s.Substring(0, s.Length - 1);
}