using System; namespace CIG.Translation { public class RawTimeSpanString : ILocalizedString { public RawTimeSpanString(TimeSpan dateTime, bool hidePartWhenZero, int showParts) { this._dateTime = dateTime; this._hidePartWhenZero = hidePartWhenZero; this._showParts = showParts; } public override string ToString() { return string.Concat(new object[] { "[TimeSpan=", this._dateTime.ToString(), ",HideZero=", this._hidePartWhenZero, ",#Parts=", this._showParts, "]" }); } public string Translate() { ILocalizedString localizedString = null; ILocalizedString localizedString2 = null; ILocalizedString localizedString3 = null; ILocalizedString localizedString4; if ((double)this._dateTime.Days > 0.0) { localizedString4 = Localization.Format(Localization.Key("day_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Days)) }); if (this._showParts >= 2 && (this._dateTime.Hours > 0 || !this._hidePartWhenZero)) { localizedString = Localization.Format(Localization.Key("hour_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Hours)) }); } if (this._showParts >= 3 && (this._dateTime.Minutes > 0 || !this._hidePartWhenZero)) { localizedString2 = Localization.Format(Localization.Key("minute_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Minutes)) }); } if (this._showParts >= 4 && (this._dateTime.Seconds > 0 || !this._hidePartWhenZero)) { localizedString3 = Localization.Format(Localization.Key("second_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Seconds)) }); } } else if (this._dateTime.Hours > 0) { localizedString4 = Localization.Format(Localization.Key("hour_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Hours)) }); if (this._showParts >= 2 && (this._dateTime.Minutes > 0 || !this._hidePartWhenZero)) { localizedString = Localization.Format(Localization.Key("minute_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Minutes)) }); } if (this._showParts >= 3 && (this._dateTime.Seconds > 0 || !this._hidePartWhenZero)) { localizedString2 = Localization.Format(Localization.Key("second_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Seconds)) }); } } else { if (this._dateTime.Minutes > 0) { localizedString4 = Localization.Format(Localization.Key("minute_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Minutes)) }); } else if (this._showParts >= 2) { localizedString4 = Localization.Literal(string.Empty); } else { localizedString4 = Localization.Format(Localization.Key("second_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Seconds)) }); } if (this._showParts >= 2 && (this._dateTime.Seconds > 0 || !this._hidePartWhenZero)) { localizedString = Localization.Format(Localization.Key("second_symbol"), new ILocalizedString[] { Localization.Literal(string.Format("{0:D}", this._dateTime.Seconds)) }); } } if (localizedString == null) { return localizedString4.Translate(); } if (localizedString2 == null) { return Localization.Concat(new ILocalizedString[] { localizedString4, Localization.Literal(" "), localizedString }).Translate(); } if (localizedString3 == null) { return Localization.Concat(new ILocalizedString[] { localizedString4, Localization.Literal(" "), localizedString, Localization.Literal(" "), localizedString2 }).Translate(); } return Localization.Concat(new ILocalizedString[] { localizedString4, Localization.Literal(" "), localizedString, Localization.Literal(" "), localizedString2, Localization.Literal(" "), localizedString3 }).Translate(); } private TimeSpan _dateTime; private bool _hidePartWhenZero; private int _showParts; } }