| 12345678910111213141516171819202122232425262728 |
- using System;
- using System.Collections.Generic;
- namespace Quadarax.Foundation.Core.Value.Formatters
- {
- /// <summary>
- /// Formatter for forms of seconds/hours/day
- /// </summary>
- public class HmsFormatter : ICustomFormatter, IFormatProvider
- {
- static Dictionary<string, string> _timeformats = new Dictionary<string, string> {
- {"S", "{0:P:Seconds:Second}"},
- {"M", "{0:P:Minutes:Minute}"},
- {"H","{0:P:Hours:Hour}"},
- {"D", "{0:P:Days:Day}"}
- };
- public string Format(string format, object arg, IFormatProvider formatProvider)
- {
- return string.Format(new PluralFormatter(),_timeformats[format], arg);
- }
- public object GetFormat(Type formatType)
- {
- return formatType == typeof(ICustomFormatter)?this:null;
- }
- }
- }
|