Not Dates, but Hours
-
@blakeyrat said in Not Dates, but Hours:
3 years Is "massive" relative immaturity?
The Mono implementation was an awful joke for a long time.
-
@pie_flavor said in Not Dates, but Hours:
@masonwheeler ... wat?
I think you mean big-VVoid
, a class created to hold an instance ofvoid.class
, which can't be constructed and therefore can only be null.
https://i.imgur.com/AEm976y.png
https://i.imgur.com/3Il2bHf.png
You can easily do that in C#:public class Void { private Void() {} }
That might be. It was a few years ago when I ran across this.
-
@boomzilla said in Not Dates, but Hours:
Why are you lying?
I'm not?
@boomzilla said in Not Dates, but Hours:
Weren't you just going on about the difference in tooling, etc?
Yeah; between .Net and Java. What's your point? What does it have to do with the post you quoted?
-
@blakeyrat said in Not Dates, but Hours:
@boomzilla said in Not Dates, but Hours:
Why are you lying?
I'm not?
Liar.
@boomzilla said in Not Dates, but Hours:
Weren't you just going on about the difference in tooling, etc?
Yeah; between .Net and Java. What's your point? What does it have to do with the post you quoted?
So you think there was some kind of parity between the tooling for .Net on Windows in 2001 and Mono on Linux in 2004? You are a very poor liar today.
-
@boomzilla said in Not Dates, but Hours:
So you think there was some kind of parity between the tooling for .Net on Windows in 2001 and Mono on Linux in 2004?
No.
When did I say I did? Quote me. I dare you.
-
@blakeyrat said in Not Dates, but Hours:
@boomzilla said in Not Dates, but Hours:
So you think there was some kind of parity between the tooling for .Net on Windows in 2001 and Mono on Linux in 2004?
No.
When did I say I did? Quote me. I dare you.
When did I say you said it? Are you really so dumb that you can't connect two thoughts together?
-
Works perfectly with my cultural settings (24 hour clock). I will use this snippet everywhere from now on, thanks for sharing!
-
@hans_mueller said in Not Dates, but Hours:
Works perfectly with my cultural settings (24 hour clock). I will use this snippet everywhere from now on, thanks for sharing!
Happy path tested. Signed off
-
@scholrlea said in Not Dates, but Hours:
if the current data format uses a solidus ('/') to separate the parts of the date, then obviously it is a USAian system and the user will want this in 12-hour AM/PM format
… AFAICT, British locale also uses solidus (
/
), but 24-hour format…@topspin said in Not Dates, but Hours:
And I guess there's other time formats besides 12h and 24h.
Actually it's 12h—12, 1… 11 am/pm—and 23h—0…23. The CLDR formats allow specifying the other two variants (11h—0…11 am/pm—and 24h—24, 1…23—as
K
andk
), but the database does not specify them as default for any locale.
-
@bulb said in Not Dates, but Hours:
… AFAICT, British locale also uses solidus (
/
), but 24-hour format…The difference is that the US locale uses slash, while in the British locale it is called "stroke"
-
@bulb Actually you sometimes see 24:00 in practice as well, but only at the end of a range. For example, a shop that closes at midnight would announce that as 24:00, not 0:00.
-
@boomzilla said in Not Dates, but Hours:
Are you really so dumb that you can't connect two thoughts together?
I guess I am, because I have no idea what you're talking about.
-
@blakeyrat said in Not Dates, but Hours:
@boomzilla said in Not Dates, but Hours:
Are you really so dumb that you can't connect two thoughts together?
I guess I am, because I have no idea what you're talking about.
Fair enough.
-
The 12h format used in the US makes about as much sense as the US date format (none whatsoever) and it makes sorting really hard: not only is the primary sorting criterion at the end (AM vs PM), but 12 comes before 1 against all expectations (being a disguised 0). A 12h format with a 0 (@Bulb 's K format) would make a lot more sense, though the regular 24h format (with padding) is clearly the best for sorting (a straight string comparison does the job).
-
At some other website, Bernie found an image
which is also very interesting: that restaurant is said to be closed "until 00:00 PM"
Did Bernie's cow-orker write that code, too? Or did their developer just copy from the same site?
-
@BernieTheBernie Not sure, but on my old phone, the clock would display 0 for both noon and midnight. Or at least one of the clocks, maybe from a weather app or something.
-
@BernieTheBernie It could be some weird combination of 12- and 24-hour times: the hour of 00:00 but the meridian part of 12:00 PM. Except midnight is 12 AM, so…
-
@pie_flavor said in Not Dates, but Hours:
C# is like Java except better in literally every way. You are a confusing individual.
Woah, C# is the better Java even in @pie_flavor's world!
-
@kazitor said in Not Dates, but Hours:
Except midnight is 12 AM
I've never agreed with this. Surely it makes more sense for 12 AM to be mid-day, i.e. the last of the AMs you get. And the obverse for 12 PM.
We should all use Zulu, the military got that right.
-
@Zecc said in Not Dates, but Hours:
@pie_flavor said in Not Dates, but Hours:
C# is like Java except better in literally every way. You are a confusing individual.
Woah, C# is the better Java even in @pie_flavor's world!
Being the better java implies it is still java. I doubt this will convince our corporate direction people (who seem to think new projects can be implemented in any language you like, as long as it's java).
-
@PleegWat said in Not Dates, but Hours:
@Zecc said in Not Dates, but Hours:
@pie_flavor said in Not Dates, but Hours:
C# is like Java except better in literally every way. You are a confusing individual.
Woah, C# is the better Java even in @pie_flavor's world!
Being the better java implies it is still java. I doubt this will convince our corporate direction people (who seem to think new projects can be implemented in any language you like, as long as it's java).
Be glad they don't think everything must be implemented in js.
-
@PleegWat said in Not Dates, but Hours:
@Zecc said in Not Dates, but Hours:
@pie_flavor said in Not Dates, but Hours:
C# is like Java except better in literally every way. You are a confusing individual.
Woah, C# is the better Java even in @pie_flavor's world!
Being the better java implies it is still java. I doubt this will convince our corporate direction people (who seem to think new projects can be implemented in any language you like, as long as it's java).
But if C# is Java, wouldn't that make them easier to convince?
-
@PleegWat said in Not Dates, but Hours:
@Zecc said in Not Dates, but Hours:
@pie_flavor said in Not Dates, but Hours:
C# is like Java except better in literally every way. You are a confusing individual.
Woah, C# is the better Java even in @pie_flavor's world!
Being the better java implies it is still java. I doubt this will convince our corporate direction people (who seem to think new projects can be implemented in any language you like, as long as it's java).
Sounds like they'd be open to Kotlin.
-
Let me add another gem produced by that guy.
Proudly presenting:public List<string> ReadDays(string _hostName, DateTime _startDate) { ... string cmdText = "SELECT DISTINCT date_format(" + FIELD_XY + ", '%Y-%m-%d') as " + FIELD_TIMESTAMP + " FROM `" + DATA_TABLE_NAME_AB + "`";
Yes, exactly: a database query to find out for what days entries are available. Because some stupid fucktard designed the field to store datetime(3) instead of strings, the smart boy uses the date_format function of myql to get them in his favorite format.
-
@BernieTheBernie said in Not Dates, but Hours:
Let me add another gem produced by that guy.
Proudly presenting:public List<string> ReadDays(string _hostName, DateTime _startDate) { ... string cmdText = "SELECT DISTINCT date_format(" + FIELD_XY + ", '%Y-%m-%d') as " + FIELD_TIMESTAMP + " FROM `" + DATA_TABLE_NAME_AB + "`";
Yes, exactly: a database query to find out for what days entries are available. Because some stupid fucktard designed the field to store datetime(3) instead of strings, the smart boy uses the date_format function of myql to get them in his favorite format.
It's been long blissful years since I last saw string glued sql query. It was good while it lasted. Go to hell.
-
@MrL said in Not Dates, but Hours:
It's been long blissful years since I last saw string glued sql query. It was good while it lasted. Go to hell.
It looks like it’s put together with constants, not user input. That’s perfectly sane, I thought?
-
@Unperverted-Vixen said in Not Dates, but Hours:
@MrL said in Not Dates, but Hours:
It's been long blissful years since I last saw string glued sql query. It was good while it lasted. Go to hell.
It looks like it’s put together with constants, not user input. That’s perfectly sane, I thought?
If they are constants, why glue strings at all? Some kind of db model is kept in constants?
-
@BernieTheBernie said in Not Dates, but Hours:
Because some stupid fucktard designed the field to store datetime(3) instead of strings
Wait, you're not supposed to do that? I thought it's storing dates as strings that's the wrong thing to do?
-
@Gąska said in Not Dates, but Hours:
@BernieTheBernie said in Not Dates, but Hours:
Because some stupid fucktard designed the field to store datetime(3) instead of strings
Wait, you're not supposed to do that? I thought it's storing dates as strings that's the wrong thing to do?
How're you going to apply your 87 regexes to it if it's not a string?
-
I'm not seeing much wrong with the latest problem. Maybe I'm
-
@pie_flavor said in Not Dates, but Hours:
There is a grand total of zero advantage, objectively, to using Java over C#
Confession: I actually like checked exceptions. So, there's at least one reason for me.
-
@MrL said in Not Dates, but Hours:
If they are constants, why glue strings at all? Some kind of db model is kept in constants?
If you're using the same field and table names in multiple queries, why not put them in constants? If you have a sane language it will do the concatenation at compile time instead of runtime. (And this looks like C# which qualifies as a sane language in that regard.)
-
@Gąska said in Not Dates, but Hours:
@BernieTheBernie said in Not Dates, but Hours:
Because some stupid fucktard designed the field to store datetime(3) instead of strings
Wait, you're not supposed to do that? I thought it's storing dates as strings that's the wrong thing to do?
Ehm, did you understand who that "stupid fucktard" is? Well, me. Now start interpretation of that convoluted sentence again...
-
@BernieTheBernie Poe's law in action.
-
Let me add another little gem:
// ReSharper disable once MemberCanBeInternal - FuckOff Resharper - Designer needs public constructor protected string DateFormat { get { DateTimeFormatInfo dateTimeInfo = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentCulture); return dateTimeInfo.DateSeparator == "/" ? "MM/dd/yy" : "dd.MM.yy"; } } public DateTimeConverter() { DateTimeFormat = DateFormat + " HH:mm:ss"; }
The "ReShaper disable" comment should be directly above the constructor.
Of course, a [UsedImplicitly] attribute (JetBrains.Annotations) would be better (again, at the right place of course).And then note his genius for defining the DateFormat. In his opinion, the order of month and dates depends on the DateSeparator (well, a similar was shown in the first post of this thread).
-
I showed code of a DateTimeConverter. Why does Kevin actually need that?
Well, because WPF is also WTF, see e.g. https://stackoverflow.com/questions/1062160/wpf-xaml-stringformat-datetime-output-in-wrong-culture
But of course, Bernie wrote a solution for that long before. He created a static class WpfLanguageSetter with one method:
public static void SetLanguage() { LanguageSetter.SetLanguage(); FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag))); }
Internally, it calls the non-WPF-version of the LanguageSetter, and then overrides some FrameWorkElement property metadata (which cannot be done e.g. in a Windows service - so the need for a separate simple LanguageSetter).
Of course, Kevin uses that non-WPF-LanguageSetter instead of the WpfLanguageSetter...
Oh Dominus Deus in caelis, dona nobis cerebra!
-
@ScholRLEA said in Not Dates, but Hours:
I have to rebuild every time I access this not-a-variable?
In many cases, that is actually the correct paradigm.... If the list is easy to create and the lifetime of the outer object is long, then keeping the values in a field will increase pressure on the GC for the entire duration.
-
@BernieTheBernie said in Not Dates, but Hours:
Oh Dominus Deus in caelis, dona nobis cerebra!
Upvote just for that.
-
Next step. Bernie cleaned up some database access classes. He made sure that the
DateTime
returned from the database is in the correct type, i.e.DateTimeKind.Utc
.There's a catch: all of Kevin's great UI design relied on
DateTime
being alwaysDateTimeKind.Local
(well, you show the user a local time, that's quite proper). So Bernie had to clean up some shitty code of Kevin (like theDateTimeConverter
above), and make sure that local time gets displayed regardless of theDateTimeKind
of theDateTime
data. But he did not find all of it.Kevin "repaired" that. Now the database class converts all
DateTime
toDateTimeKind.Local
, and the UI will display exactly what it gets, never needing to worry about theDateTimeKind
it receives.Some people will never learn how to handle Dates correctly.
-
@BernieTheBernie said in Not Dates, but Hours:
Some people will never learn how to handle dates correctly.
Social awkwardness thread is .