- Published on
DateTime in .NET - Things I learned (#1?)
- Authors
- Name
- Tylah Kapa
- @jadekapa
Here's what I looked like while learning about DateTime in .NET:
What do I think they are?
Like with strings, I can't be too sure.
I know that at its core, DateTime mostly works on some form of integer as "ticks" to determine the current time. DateTime comparison and addition then becomes quite easy.
Though I couldn't say what the default Time Zone information is and how that gets converted.
5 things that I learned while looking at DateTime
- DateTime data is stored as a
ulong
but is actually treated asbytes
- The first 62 Bits is the value of 100-nanosecond ticks
- Bits 63-64 are to denote
DateTimeKind
- C# DateTimes have a range of 01/01/0001 12:00:00 AM until 31/12/9999 11:59:59 PM
- The
DateTimeKind
Enum can be helpful for ensuring you're dealing with DateTimes Consistently - Wtf is the
|
Operator?- It's called a Bitwise OR Operator
- It's REALLY interesting, and is used to combine add Bits together.
- I hate it
- But what are Structs actually?
- There's some interesting differences between Structs and Classes outlined in this blog https://www.c-sharpcorner.com/blogs/difference-between-struct-and-class-in-c-sharp
What were the differences?
I thought that the DateTime data was just a simple ulong
, but it's clear that it's being used in a more complex way than I initially thought. I feel like I've barely scratched the surface on this one, so I'm excited to jump back into it later.