2
The user will enter a date (DD/MM/YYYY), and the Program must return whether the date day is useful or not.
I’ve been part of the code considering Weekend (Saturday and Sunday) not useful. I want to know if there is any way (without using database/ Tables) to consider holidays as well.
this.DataIni = Convert.ToDateTime(dtIniString);
diaSemana = DataIni.DayOfWeek.ToString();
if(diaSemana == "Saturday" || diaSemana == "Sunday")
{}
probably not, given that many holidays do not have specific days and will change from year to year..
– João Paulo Amorim
Holidays should be static data and defined in your application, has no way of knowing if the day is a holiday or not with nothing to help!
– Marconi
"holidays" is something very broad, because it depends on the country (and in Brazil, for example, there are still state holidays, municipal, etc.), there are fixed (fall every year on the same day), furniture (carnival, easter, etc., that every year fall on different dates, but how to calculate) and so on. So it all depends on what holidays you want to consider. If you don’t want to consult from a bank, you will have to use a External API, or a lib, or manually generate dates
– hkotsubo
As holidays are varied, you will need an API, like this one, for example: http://www.calendario.com.br/api_feriados_municipais_estaduais_nacionais.php
– Wanderson Rodrigo
I get it, thank you. I believe API usage is the best option for me at the moment.
– Rebeca Nonato
Going a little further, there are holidays (or so "non-working days") that depend on the context, like the "amendments" (when the holiday falls on Thursday, the sixth is also working day? depends on where you work), insurance companies do not work on security day, the judiciary has its own holidays and so on. It may not apply to your specific case, but the definition of a working day (in the sense of "the day when people work") varies greatly depending on the context.
– hkotsubo
As mentioned by some colleagues, holiday is country specific, so there is no way to know if it is a holiday without a "base" of previously "populated" consultation. The expression "database" is very broad and does not refer only, for example, to SQL Server, Oracle, etc., but to everything that can somehow "store" information. In your question you say "no database/tables", I believe you are referring to relational databases, or not. Ever thought of using a text file where there are all the dates of registered holidays?
– Leandro Amarilha
Guys, How to Signal the Answer to the Question? As the question is pending, I can’t "Close" it.
– Rebeca Nonato