SHARE
TWEET

Untitled

a guest Mar 26th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static void Datas()
  2.         {
  3.             var agora = DateTime.UtcNow;
  4.             Console.WriteLine(agora.AddHours(-30).Humanize()); //ontem
  5.             Console.WriteLine(agora.AddHours(25).Humanize()); //amanhã
  6.             Console.WriteLine(agora.AddMinutes(-2).Humanize()); //2 minutos atrás
  7.             Console.WriteLine(agora.AddMinutes(2).Humanize()); //em um minuto
  8.             Console.WriteLine(agora.AddMonths(-11).Humanize()); //11 meses atrás
  9.             Console.WriteLine(agora.AddMonths(-13).Humanize()); //um ano atrás
  10.             Console.WriteLine(agora.AddYears(-10).Humanize()); //10 anos atrás
  11.             Console.WriteLine(TimeSpan.FromMinutes(2).Humanize()); //2 minutos
  12.             Console.WriteLine(TimeSpan.FromMinutes(-2).Humanize()); //2 minutos
  13.             Console.WriteLine(TimeSpan.FromDays(28).Humanize()); //4 semanas
  14.             Console.WriteLine(TimeSpan.FromDays(365 * 4).Humanize()); //208 semanas
  15.             Console.WriteLine(TimeSpan.FromMilliseconds(1299630020).Humanize()); //2 semanas
  16.             Console.WriteLine(TimeSpan.FromMilliseconds(1299630020).Humanize(3)); //2 semanas, 1 dia, 1 hora
  17.             Console.WriteLine(TimeSpan.FromMilliseconds(1).Humanize()); //1 milisegundo
  18.             Console.WriteLine(TimeSpan.FromMilliseconds(2).Humanize()); //2 milisegundos
  19.             Console.WriteLine(TimeSpan.FromDays(1).Humanize()); //1 dia
  20.             Console.WriteLine(TimeSpan.FromDays(2).Humanize()); //2 dias
  21.             Console.WriteLine(TimeSpan.FromDays(16).Humanize()); //2 semanas
  22.             DateTime dataFim = new DateTime(2019, 6, 30);
  23.             TimeSpan diferenca = dataFim - agora;
  24.             Console.WriteLine("Em " + TimeSpanHumanizeExtensions.Humanize(diferenca)); //Em 14 semanas
  25.             Console.WriteLine(DateTimeOffset.UtcNow.AddHours(1).Humanize()); // em um hora
  26.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top