mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-06 22:24:27 +02:00
Updated Examples and Recipes (markdown)
@@ -188,7 +188,7 @@ Here is a function to perform that conversion:
|
|||||||
|
|
||||||
The variable `utc` holds the “year + us” as a time point with microseconds precision. This time point counts microseconds, including leap seconds, since 1970-01-01 00:00:00 UTC.
|
The variable `utc` holds the “year + us” as a time point with microseconds precision. This time point counts microseconds, including leap seconds, since 1970-01-01 00:00:00 UTC.
|
||||||
|
|
||||||
The next step is find when the day started that is associated with `utc`. To do this one must convert `utc` back to “Unix time”, and then truncate that time point to a precision of `days`, resulting in the variable `dp`. `dp` is a count of days since 1970-01-01. Since the required epoch is 1958-01-01, this is taken into account in creating `d`, the first value needed in the return type.
|
The next step is to find when the day started that is associated with `utc`. To do this one must convert `utc` back to “Unix time”, and then truncate that time point to a precision of `days`, resulting in the variable `dp`. `dp` is a count of days since 1970-01-01. Since the required epoch is 1958-01-01, this is taken into account in creating `d`, the first value needed in the return type.
|
||||||
|
|
||||||
Now the number of microseconds since the start of the day needs to be computed. The start of the day, `dp`, is converted back into the leap-second aware system, and subtracted from the microsecond time point: `utc`. The variable `us` is reused to hold “microseconds since midnight”. Now it is a simple computation to split this into milliseconds since midnight, and microseconds since the last millisecond.
|
Now the number of microseconds since the start of the day needs to be computed. The start of the day, `dp`, is converted back into the leap-second aware system, and subtracted from the microsecond time point: `utc`. The variable `us` is reused to hold “microseconds since midnight”. Now it is a simple computation to split this into milliseconds since midnight, and microseconds since the last millisecond.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user