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 horaDoVelti = "09:23 12:08 13:08"; var horaTeste = horaDoVelti.Split(' '); var horarioDeEntrada = Converter(horaTeste[0].Trim()); var horarioDeAlmocoEnt = Converter(horaTeste[1].Trim()); var horarioDeAlmocoSai = Converter(horaTeste[2].Trim()); var horarioDeSaida = Converter(string.Format("{0}:{1}", HoraAtual().Hour, HoraAtual().Minute)); //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 DateTime HoraAtual() { return TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time"));} 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
num 1
Overriding call parent & child class
BFS DFS stack vs recursive
Better Random number blocks
Leapyear
Validate or get the check digit of a segment of a Windows 8 / 10 activation installation ID
SceneGraph Interviewee Task
mo3dal
Code
GEFCSADX