Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HourCouter
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { var horarioDeEntrada = Converter("08:08"); var horarioDeAlmocoEnt = Converter("11:47"); var horarioDeAlmocoSai = Converter("12:50"); var horarioDeSaida = Converter("17:31"); //Your code goes here var entrada = DateTime.Now.Date.AddHours(horarioDeEntrada.Hora).AddMinutes(horarioDeEntrada.Minuto); var entAlmoco = DateTime.Now.Date.AddHours(horarioDeAlmocoEnt.Hora).AddMinutes(horarioDeAlmocoEnt.Minuto); var saiAlmoco = DateTime.Now.Date.AddHours(horarioDeAlmocoSai.Hora).AddMinutes(horarioDeAlmocoSai.Minuto); var saida = DateTime.Now.Date.AddHours(horarioDeSaida.Hora).AddMinutes(horarioDeSaida.Minuto); var padrao = new TimeSpan(8,30,0); TimeSpan tempo = saida - entrada - (saiAlmoco - entAlmoco); TimeSpan restante = padrao - tempo; Console.WriteLine("Deveria sair: " + (entrada + padrao + (saiAlmoco - entAlmoco)).ToString("HH:mm:ss")); Console.WriteLine("Se sair agora da: " + tempo); Console.WriteLine("Fica faltando: " + restante); } public static Horario Converter(string hora) { var sep = hora.Split(':'); return new Horario(){Hora = int.Parse(sep[0]), Minuto = int.Parse(sep[1])}; } } public class Horario { public int Hora { get; set; } public int Minuto { get; set; } } }
run
|
edit
|
history
|
help
0
Eliminate duplicates char in string either upper or lower case
Q-2 dotnet
Types
Fórum Mimicking Array Names Being Defined at Runtime
Linq FirstOrDefault() null check in c#
Planet-D
Vowel
Async Multithreading
Bubble Sort
partial method