private static string GenerateFileName(string channelCode, string recordingHostCode, string recordingSource,DateTime from, DateTime to, string fileExtension)
return string.Format("{0}_{1}_{2}_{3:yyyyMMddHHmmss}_{4:yyyyMMddHHmmss}{5}", channelCode, recordingHostCode, recordingSource, @from, to, fileExtension);
public static DateTime ConvertToUtc(DateTime input, string timezoneId)
TimeZoneInfo systemTimeZoneById = TimeZoneInfo.FindSystemTimeZoneById(timezoneId);
return TimeZoneInfo.ConvertTimeToUtc(new DateTime(input.Ticks, DateTimeKind.Unspecified), systemTimeZoneById);
public static void Main()
const string channelCode = "USR083KESN-FM";
const string recordingHostCode = "us-east";
const string recordingSource = "i0";
const string extension = ".vs450.mp4";
const string timezone = "Eastern Standard Time";
const int broadcastDateStartOffsetInHours = 0;
const int broadcastDurationInHours = 16;
DateTime fromDate = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day);
DateTime lastAssetEndDate = ConvertToUtc(fromDate.Add(TimeSpan.FromHours(broadcastDateStartOffsetInHours)).Add(TimeSpan.FromHours(broadcastDurationInHours)), timezone);
DateTime currentDate = ConvertToUtc(fromDate.Add(TimeSpan.FromHours(broadcastDateStartOffsetInHours)), timezone);
Console.WriteLine("From : {0:yyyyMMddHHmmss}", currentDate);
Console.WriteLine("To : {0:yyyyMMddHHmmss}", lastAssetEndDate);
Console.WriteLine("Filename: {0}", GenerateFileName(channelCode, recordingHostCode, recordingSource, currentDate, lastAssetEndDate, extension));