|
private readonly bool _mUseQuoteValue
Original post[^]
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Maybe this should be the proper naming:
const bool _alwaysWrong= true
It does not solve my Problem, but it answers my question
Chemists have exactly one rule: there are only exceptions
modified 19-Jan-21 21:04pm.
|
|
|
|
|
99 Bottles of Beer | Language Malbolge[^]
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
|
I've heard of it. I think the syntax is too verbose.
Real programmers use butterflies
|
|
|
|
|
So, when will we see a malbolge code generator article?
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
That would be evil
Real programmers use butterflies
|
|
|
|
|
Yes?
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
Found this gem in our codebase...
public static class DateTimeExtensions
{
public static DateTime EndOfMonth(this DateTime dt)
{
return dt.Date.AddMonths(1).AddDays(-1);
}
}
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Ah.
I can see a problem developing there. I assume he tested it on the first of the month, and it worked fine?
Here is my stab at it:
public static DateTime LastOfMonth(this DateTime dt)
{
int daysInMonth = DateTime.DaysInMonth(dt.Year, dt.Month);
return dt.FirstOfMonth().AddDays(daysInMonth - 1).AtMidnight();
} As seen before: DateTime Extensions to Make Some Simple Tasks a Little More Readable[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Actually, he had unit tests in place, but all the dates tested were on the first day of the month.
My fix was:
return new DateTime(dt.Year, dt.Month, 1).AddMonths(1).AddDays(-1);
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
modified 15-Jun-20 9:14am.
|
|
|
|
|
I guess it's true for tests as well: GIGO ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
And why not simply use DateTime.DaysInMonth ?
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Because the programmer wanted the attention of being presented here?
|
|
|
|
|
Makes sense
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
|
Rob Grainger wrote: return new DateTime(dt.Year, dt.Month, 1).AddMonths(1).AddDays(-1);
This is exactly my EndOfMonth extension function in dotNet.
|
|
|
|
|
This gets you the last *date* of the month, but if you’re actually looking for the “end” of the month and don’t want fencepost errors, you’d want the first of the next month (with no time component) and then use a strict less-than in your comparisons.
|
|
|
|
|
Not to be pernickity but I guess it is going to depend on the intention of the method. If a trial runs for a month then perhaps from a given date that would be the end of the month
However, the intention is not clear from the method name so one may very well assume that it represents the date for the last day in the month of the given date.
|
|
|
|
|
Personally, I feel that an extension method on DateTime should apply to all possible DateTime instances. Otherwise, it can be defined to match circumstances, as long as that is clear from the name.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
30 days have September, all the rest I can't remember.
|
|
|
|
|
I resemble that remark.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
|
That can't be real. Come on. How stupid an entire team has to be to let this run in production. Has to be a joke. And if this is intranet, why are you bothered with form based authentication? Just do AD look up or something.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
I want to believe this is a joke too and that an entire team cannot be that stupid...
But I'm not so sure
I once worked for a company who had their own "security framework".
The idea was that you entered a username and password, the application would use those to login to SQL Server and if that succeeded you were logged in.
So a user in SQL Server was a user in the system and a user in the system couldn't exist without a user in SQL Server.
It supported Windows authentication too.
The application had a form to enter new users and those users would be added in SQL Server too.
It was a WinForms application on intranet so I guess it wasn't much of an issue, but it's really not how to do authentication
I think we ran into some issues at one point though.
They built it when I was already an employee and I advised against it and advised a more "traditional" approach, but I was just a junior back then and according to the technical director this really was the best method.
Cost him months to build too
I just remembered the issue we ran into!
After a backup or some such, all users ended up being "orphaned" and everybody lost access to the database and the application.
Happened more than once too.
A 200+ employee company
|
|
|
|