#region Copyright /* * Copyright © 2014-2016 NetApp, Inc. All Rights Reserved. * * CONFIDENTIALITY NOTICE: THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION OF * NETAPP, INC. USE, DISCLOSURE OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR * EXPRESS WRITTEN PERMISSION OF NETAPP, INC. */ #endregion #region Using Directives using SolidFire.Exceptions; using System; #endregion namespace SolidFire.Volume { public static class VolumeUtilities { /// /// Build a time string formatted like HH:mm:ss from a mix of values in days, hours, minutes /// /// Number of days to add to the hours value /// Number of hours (days will be multiplied by 24 and added to this if supplied) /// Number of minutes /// Number of seconds /// Time string in the format of HH:mm:ss. public static string BuildTimeString(ulong days = 0, ulong hours = 0, ulong minutes = 0, ulong seconds = 0) { if (seconds > 59) { throw new ParameterException("Seconds must be between 0 and 59"); } if (minutes > 59) { throw new ParameterException("Minutes must be between 0 and 59"); } var hoursTotal = hours + (days * 24); var hoursMinutesSeconds = string.Format("{0}:{1}:{2}", hoursTotal.ToString().PadLeft(2, '0'), minutes.ToString().PadLeft(2, '0'), seconds.ToString().PadLeft(2, '0')); return hoursMinutesSeconds; } /// /// Change a weekday string into an integer representing the day of the week from 0 - 6. /// /// The Pascal case name of the weekday. /// An integer representing the day of the week from 0 (Sunday) to 6 (Saturday) public static int ConvertDayNameToValue(string name) { return (int)(DayOfWeek)Enum.Parse(typeof(DayOfWeek), name, true); } } }