Skip to content

Commit

Permalink
ThousandNumberInfo for numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
grandsilence committed May 2, 2018
1 parent 354584c commit 4a5b020
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Text/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -295,7 +296,26 @@ public static string Win1251ToUTF8(this string source)
return win1251.GetString(win1251Bytes);
}

/// <summary>
/// Возращает тип форматирование числа с разделением тысяч.
/// </summary>
public static NumberFormatInfo ThousandNumberFormatInfo
{
get {
// ReSharper disable once InvertIf
if (_thousandNumberFormatInfo == null)
{
_thousandNumberFormatInfo = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
_thousandNumberFormatInfo.NumberGroupSeparator = " ";
}

return _thousandNumberFormatInfo;
}
}
private static NumberFormatInfo _thousandNumberFormatInfo;

#region Predicated

/*
/// <summary>
/// Проверяет содержит ли строка полезные данные, т.е. не пуста и не является сплошными пробелами или отступами.
Expand Down Expand Up @@ -323,6 +343,7 @@ public static string Win1251ToUTF8(this string source)
private static readonly DateTime Jan1St1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static ulong MillisecondsFrom1970 => (ulong) (DateTime.UtcNow - Jan1St1970).TotalMilliseconds;
*/

#endregion
}
}

0 comments on commit 4a5b020

Please sign in to comment.