numpy 2.0.0
src/multiarray/_datetime.h File Reference

Go to the source code of this file.

Functions

NPY_NO_EXPORT void PyArray_DatetimeToDatetimeStruct (npy_datetime val, NPY_DATETIMEUNIT fr, npy_datetimestruct *result)
NPY_NO_EXPORT void PyArray_TimedeltaToTimedeltaStruct (npy_timedelta val, NPY_DATETIMEUNIT fr, npy_timedeltastruct *result)
NPY_NO_EXPORT npy_datetime PyArray_DatetimeStructToDatetime (NPY_DATETIMEUNIT fr, npy_datetimestruct *d)
NPY_NO_EXPORT npy_datetime PyArray_TimedeltaStructToTimedelta (NPY_DATETIMEUNIT fr, npy_timedeltastruct *d)

Function Documentation

NPY_NO_EXPORT npy_datetime PyArray_DatetimeStructToDatetime ( NPY_DATETIMEUNIT  fr,
npy_datetimestruct d 
)

== End of section adapted from mx.DateTime ==

System Message: SEVERE/4 (<string>, line 1)
Missing matching underline for section title overline.

==================================================
Parsing DateTime struct and returns a date-time number
=================================================

<blockquote> Structure is assumed to be already normalized</blockquote>

Create a datetime value from a filled datetime struct and resolution unit.

<

The absolute number of days since Jan 1, 1970
This is just 7-days for now.
Invalid business day
offset to adjust first week
only 2.6 hours
get number of seconds as a postive or negative number
only 9.2 secs
Shouldn't get here

NPY_NO_EXPORT void PyArray_DatetimeToDatetimeStruct ( npy_datetime  val,
NPY_DATETIMEUNIT  fr,
npy_datetimestruct result 
)
Fill the datetime struct from the value and resolution unit.

Note that what looks like val / N and val % N for positive numbers maps to [val - (N-1)] / N and [N-1 + (val+1) % N] for negative numbers (with the 2nd value, the remainder, being positive in both cases).
A week is the same as 7 days
Number of business days since Thursday, 1-1-70
A buisness day is M T W Th F (i.e. all but Sat and Sun.) Convert the business day to the number of actual days.

Must convert [0,1,2,3,4,5,6,7,...] to
[0,1,4,5,6,7,8,11,...]
and [...,-9,-8,-7,-6,-5,-4,-3,-2,-1,0] to
[...,-13,-10,-9,-8,-7,-6,-3,-2,-1,0]
Recall how C computes / and % with negative numbers
entire range is only += 2.6 hours
tmp (number of fs) will be positive after this segment
we are at the last second
entire range is only += 9.2 seconds

NPY_NO_EXPORT npy_datetime PyArray_TimedeltaStructToTimedelta ( NPY_DATETIMEUNIT  fr,
npy_timedeltastruct d 
)
Create a timdelta value from a filled timedelta struct and resolution unit.

This is just 7-days for now.
What is the meaning of a relative Business day?
This assumes you want to take the day difference and convert it to business-day difference (removing 2 every 7).
only 2.6 hours
only 9.2 secs
Shouldn't get here

References ymdstruct::day, days_to_ymdstruct(), hmsstruct::hour, hmsstruct::min, ymdstruct::month, NPY_FR_B, NPY_FR_D, NPY_FR_h, NPY_FR_m, NPY_FR_M, NPY_FR_s, NPY_FR_W, NPY_FR_Y, hmsstruct::sec, seconds_to_hmsstruct(), and ymdstruct::year.

NPY_NO_EXPORT void PyArray_TimedeltaToTimedeltaStruct ( npy_timedelta  val,
NPY_DATETIMEUNIT  fr,
npy_timedeltastruct result 
)
FIXME: Overflow is not handled at all
To convert from Years, Months, and Business Days, multiplication by the average is done
Fill the timedelta struct from the timedelta value and resolution unit.

Note that what looks like val / N and val % N for positive numbers maps to [val - (N-1)] / N and [N-1 + (val+1) % N] for negative numbers (with the 2nd value, the remainder, being positive in both cases).
Number of business days since Thursday, 1-1-70
entire range is only += 9.2 hours
entire range is only += 2.6 seconds