QLNet.Period.ToShortString C# (CSharp) Method

ToShortString() public method

public ToShortString ( ) : string
return string
        public string ToShortString()
        {
            string result = string.Empty;
            int n = Length;
            int m = 0;
            switch (TimeUnit)
            {
                case TimeUnit.Days:
                    if (n >= 7)
                    {
                        m = n / 7;
                        result += m + "W";
                        n = n % 7;
                    }

                    return (n != 0 || m == 0) ? result + n + "D" : result;

                case TimeUnit.Weeks:
                    return result + n + "W";

                case TimeUnit.Months:
                    if (n >= 12)
                    {
                        m = n / 12;
                        result += n / 12 + "Y";
                        n = n % 12;
                    }
                    return (n != 0 || m == 0) ? result + n + "M" : result;

                case TimeUnit.Years:
                    return result + n + "Y";

                default:
                    throw new ApplicationException("unknown time unit (" + TimeUnit + ")");
            }
        }

Usage Example

Ejemplo n.º 1
0
        public override string name()
        {
            string res = familyName_;

            if (tenor_ == new Period(1, TimeUnit.Days))
            {
                if (fixingDays_ == 0)
                {
                    res += "ON";
                }
                else if (fixingDays_ == 1)
                {
                    res += "TN";
                }
                else if (fixingDays_ == 2)
                {
                    res += "SN";
                }
                else
                {
                    res += tenor_.ToShortString();
                }
            }
            else
            {
                res += tenor_.ToShortString();
            }
            res = res + " " + dayCounter_.Name;
            return(res);
        }
All Usage Examples Of QLNet.Period::ToShortString