|
Kubuntu installed, Windows fonts moved over to it (because I really don't care for the Linux fonts), and as a temporary stop-gap, I copied the contents of my Windows hosts file to my Linux hosts file.
I'm currently evaluating a minimal solution for Pi-Hole. I'll probably just get a raspberry Pi and be done with it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I usually just save DateTime.Now for a DB transaction into some datetime field. If a report or UI needs to show the date/time, it's formatted accordingly, for example MM/dd/yyyy HH:mm:ss tt (for us US people).
So, I have a "When checked in" (start time) and I have a "When checked out" (stop time) for tracking employee hours worked. And I compute the hours/minutes/seconds worked basically as "check out time" - "check in time", displayed as "hh:mm:ss" (they don't work more than 24 hours, haha.)
So, on occasion, my time worked is off by 1 second comparing start time and stop time as hh:mm:ss.
Why? Because I of the millisecond component to date/time!
So I coded:
DateTime now = DateTime.Now;
now = now.AddMilliseconds(-now.Millisecond);
which works fine, particularly since the DB stores only 3 digits for the ms component, but out of curiosity, I google "getting DateTime without milliseconds" and come across this SO page.
And I wonder, WTF is all this crazy stuff they're doing. Lower down, I find my solution, and I read this:
The Millisecond property gives an integer between 0 and 999 (inclusive). So if the time of day before the operation was, say, 23:48:49.1234567, then that integer will be 123, and the time of day after the operation is 23:48:49.0004567. So it has not truncated to a whole number of seconds.
OMG. Seriously? OK, I guess that makes sense because underlying DateTime is actually Ticks , so subtracting off just the integer portion of the ms isn't necessarily going to give me an actual tick at exactly the second.
And to make things more complicated, there's the "Kind" -- Local, UTC, or undefined. Oh good grief.
So I'm going with the solution in one of the earlier SO posts that looks like this:
new DateTime(date.Ticks - (date.Ticks % resolution), date.Kind);
The lesson learned (over and over) is that you think something is simple, and it isn't.
The other lesson learned is, thank God for people smarter than me!
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
modified 15-Sep-18 17:59pm.
|
|
|
|
|
Congrats on grabbing 1st place with your latest article...well deserved!
Everyone has a photographic memory; some just don't have film. Steven Wright
|
|
|
|
|
Thanks! I was surprised though, I really thought another article would win (can't find the link to it right now, sigh)
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
NOBODY is smarter than you!
Keep your friends close. Keep Kill your enemies closer.
The End
|
|
|
|
|
S'truth !
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
R. Giskard Reventlov wrote: NOBODY is smarter than you!
Hah! I'm smart enough to know that's not true.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Marc Clifton wrote: I'm smart enough to know that's not true. This is called modesty in my town
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I am the wisest man alive, for I know one thing, and that is that I know nothing. ~Socrates
|
|
|
|
|
I'm afraid I'm not that pedantic with my timesheet - 1 second either way is just fine by me <snicker>.
Seriously 1 second difference in a timekeeping system, way too precise. The only system I worked on measured in 15 minute blocks.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: measured in 15 minute blocks.
Exactly
|
|
|
|
|
So how does your boss know you're not clocking out at 7:59:59?
|
|
|
|
|
Boss does not care!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Seriously 1 second difference in a timekeeping system, way too precise.
I agree, but I wanted to start with precision down to the second and let my client decide if his customers would want a more granular precision and then go from there.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Ah commercial software, the place where you need to cater for the silliest requirements because some pillock of a salesman will try and sell it as a benefit.
Ah commercial software where you cannot tell the user they are complete idiots because their requirements make no sense in the real world.
2 reasons I went to corporate development all those years ago (and the money was good).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: pillock of a salesman
Isn't this redundantly redundant?
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
True but calling them just salesmen does not convey my sentiment towards them.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi, I've been using the code on the post on that same SO thread you mention that makes use of TimeSpan.TicksPerSecond and other TimeSpan values to truncate to several different values:[^]
cheers, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Oooh, that one is even better! Thanks!
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Marc Clifton wrote: ...MM/dd/yyyy HH:mm:ss tt (for us US people).
You f***en weirdos.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
|
Slacker007 wrote: Try storing your date times as DATETIME2 in the database, if SQL Server.
Also good to know. More learning.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Slacker is right in my opinion.
You should always use Datetime2 for new work[^]. It's not just having better compatibility with other databases. But also with DateTime in .Net.
If you change datatype in the db to DateTime2(0), the fractional seconds are automatically stripped, and the problem is solved.
|
|
|
|
|
Marc Clifton wrote: new DateTime(date.Ticks - (date.Ticks % resolution), date.Kind);
Is that is going to work if they work from 12:00 midnight to 8 am when daylight savings time switches?
|
|
|
|
|
Ha, thats easy, you want to store some timestamps.
Ill use DateTime.Now. to string().
gets me 01/02/2018 11:58:00
Ah good.
next day. F***. Person installed on server, and language in american. I dont know which is month and day.
fix: DateTime.Now.toString("DD/MM/YYYY hh:mm:ss")
next day. F***. the time is in 12 hour format and says I only did 1 hour of work yesterday.
fix: DateTime.Now.toString("DD/MM/YYYY HH:mm:ss")
add some uses case tests.
next day. it still works. good.
2 months later. deployed to 100 clients.
next day. All times off by 1 hour (DST). FFS
|
|
|
|