20 lines
697 B
C#
20 lines
697 B
C#
using System;
|
|
using System.Globalization;
|
|
|
|
namespace StellaOps.Provcache;
|
|
|
|
public sealed partial class ProvcacheOptions
|
|
{
|
|
/// <summary>
|
|
/// Compute time window epoch from a timestamp based on the configured bucket size.
|
|
/// </summary>
|
|
/// <param name="timestamp">The timestamp to compute the epoch for.</param>
|
|
/// <returns>The epoch identifier string.</returns>
|
|
public string ComputeTimeWindow(DateTimeOffset timestamp)
|
|
{
|
|
var bucketTicks = TimeWindowBucket.Ticks;
|
|
var epoch = timestamp.UtcTicks / bucketTicks * bucketTicks;
|
|
return new DateTimeOffset(epoch, TimeSpan.Zero).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture);
|
|
}
|
|
}
|