Click here to Skip to main content
15,898,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do i make Humanizer not display milliseconds?

i don't want that last milliseconds in my result

how do i remove this?

Is there any method to do that or to remove that last milliseconds part

I am using Humanizer GitHub Humanizer[^] to convert Timespan to human readable time

see below the image
[^]

if anyone know this then please help

thanks

What I have tried:

i am doing it like this :-

C#
Console.WriteLine("Time Remaining :- {0}", timeRemaining.Humanize(5));
Posted
Updated 4-Nov-17 21:55pm

Better write an Extension Method[^] to remove the milliseconds/millisecond instead fo refactoring the entire library.

using System;
using Humanizer;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = TimeSpan.FromMilliseconds(1).Humanize().RemoveMilliSeconds();
        }
    }

    public static class HumanizerExtension
    {
        public static string RemoveMilliSeconds(this string s)
        {
           return s.Replace("millisecond", "").Replace("milliseconds", "");
        }
    }
}
 
Share this answer
 
Comments
Palash Sachan 5-Nov-17 11:50am    
yeah this solves my problem of removing the milliseconds..although i was looking for if any method they have it..but you gave this trick to solve it and now i have just edited the code like this :- return s.Contains("milliseconds") ? s.Substring(0, s.LastIndexOf(',')) : s.Contains("no time") ? "Calculating..." : s;

thank you sir :)
Karthik_Mahalingam 5-Nov-17 11:54am    
Welcome:)
You should talk to the people who created it - they should provide technical support and will know more about their product than we will. If they don't, then find another control, and use that!
 
Share this answer
 
Comments
Palash Sachan 5-Nov-17 11:46am    
hi sir, thanks for the reply..as you said i have posted the issue there.thanks :)
 
Share this answer
 
Comments
Palash Sachan 5-Nov-17 11:45am    
hi, thanks for the reply sir..i know and i have read the documentation..and i think there is no method to remove this..thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900