Esempio n. 1
0
    /// <summary>
    /// Returns a string representation padding the leading edge with
    /// zeros if necessary to make up the number of characters
    /// </summary>
    /// <param name="MinimumDigits">The minimum number of digits that the string must contain</param>
    /// <returns>The padded string representation</returns>
    public string ToString(int MinimumDigits)
    {
        string base36Value = Base36.NumberToBase36(numericValue);

        if (base36Value.Length >= MinimumDigits)
        {
            return(base36Value);
        }
        else
        {
            string padding = new string('0', (MinimumDigits - base36Value.Length));
            return(string.Format("{0}{1}", padding, base36Value));
        }
    }
        private static void Base36Tests()
        {
            long ticks     = DateTime.Now.Ticks;
            long baseTicks = ticks - 3656158440062976;

            // 10000000000
            // 01234567890
            Debug.WriteLine(baseTicks);
            Debug.WriteLine(new DateTime(baseTicks));  // Beginning of epoch (11 digit Base36 number)
            Base36 x = "100000000000";

            Debug.WriteLine(new DateTime(baseTicks + x.NumericValue));  // End of 11 digit space (approx 400 yrs)
            Debug.WriteLine(Base36.NumberToBase36(ticks - baseTicks));
            Debug.WriteLine(Base36.NumberToBase36(ticks - baseTicks).Length);

            // Write out the number for some random date in the future
            Debug.WriteLine(Base36.NumberToBase36(new DateTime(2345, 1, 1).Ticks - baseTicks));
        }
Esempio n. 3
0
 /// <summary>
 /// Returns a string representation of the Base36 number
 /// </summary>
 /// <returns>A string representation</returns>
 public override string ToString()
 {
     return(Base36.NumberToBase36(numericValue));
 }