Skip to content

Commit

Permalink
Fixed #363
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Rogier committed Sep 30, 2024
1 parent 4a81d8e commit d699124
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 25 deletions.
6 changes: 3 additions & 3 deletions include/ocilibc/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -11449,7 +11449,7 @@ OCI_SYM_PUBLIC boolean OCI_API OCI_IntervalFromTimeZone
* @param hour - Place holder for hours value
* @param min - Place holder for minutes value
* @param sec - Place holder for seconds value
* @param fsec - Place holder for fractional part of seconds value
* @param nsec - Place holder for nanoseconds value
*
* @return
* TRUE on success otherwise FALSE
Expand All @@ -11463,7 +11463,7 @@ OCI_SYM_PUBLIC boolean OCI_API OCI_IntervalGetDaySecond
int * hour,
int * min,
int * sec,
int * fsec
int * nsec
);

/**
Expand Down Expand Up @@ -11495,7 +11495,7 @@ OCI_SYM_PUBLIC boolean OCI_API OCI_IntervalGetYearMonth
* @param hour - Hour value
* @param min - Minute value
* @param sec - Second value
* @param fsec - Fractional part of the seconds
* @param nsec - Nanoseconds value
*
* @return
* TRUE on success otherwise FALSE
Expand Down
27 changes: 22 additions & 5 deletions include/ocilibcpp/detail/Interval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,42 @@ inline int Interval::GetMilliSeconds() const

GetDaySecond(day, hour, minutes, seconds, milliseconds);

return milliseconds;
return milliseconds / 1000000;
}

inline void Interval::SetMilliSeconds(int value)
{
int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0;

GetDaySecond(day, hour, minutes, seconds, milliseconds);
SetDaySecond(day, hour, minutes, seconds, value * 1000000);
}

inline int Interval::GetNanoSeconds() const
{
int day = 0, hour = 0, minutes = 0, seconds = 0, nanoseconds = 0;

GetDaySecond(day, hour, minutes, seconds, nanoseconds);

return nanoseconds;
}

inline void Interval::SetNanoSeconds(int value)
{
int day = 0, hour = 0, minutes = 0, seconds = 0, nanoseconds = 0;

GetDaySecond(day, hour, minutes, seconds, nanoseconds);
SetDaySecond(day, hour, minutes, seconds, value);
}

inline void Interval::GetDaySecond(int &day, int &hour, int &min, int &sec, int &fsec) const
inline void Interval::GetDaySecond(int &day, int &hour, int &min, int &sec, int &nanosec) const
{
core::Check(OCI_IntervalGetDaySecond(*this, &day, &hour, &min, &sec, &fsec));
core::Check(OCI_IntervalGetDaySecond(*this, &day, &hour, &min, &sec, &nanosec));
}

inline void Interval::SetDaySecond(int day, int hour, int min, int sec, int fsec)
inline void Interval::SetDaySecond(int day, int hour, int min, int sec, int nanosec)
{
core::Check(OCI_IntervalSetDaySecond(*this, day, hour, min, sec, fsec));
core::Check(OCI_IntervalSetDaySecond(*this, day, hour, min, sec, nanosec));
}

inline void Interval::GetYearMonth(int &year, int &month) const
Expand Down
24 changes: 19 additions & 5 deletions include/ocilibcpp/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3328,6 +3328,20 @@ namespace ocilib
*/
void SetMilliSeconds(int value);

/**
* @brief
* Return the interval nano seconds value
*
*/
int GetNanoSeconds() const;

/**
* @brief
* Set the interval nano seconds value
*
*/
void SetNanoSeconds(int value);

/**
* @brief
* Extract the date / second parts from the interval value
Expand All @@ -3336,13 +3350,13 @@ namespace ocilib
* @param hour - Place holder for Hour value
* @param min - Place holder for Minutes value
* @param sec - Place holder for Seconds value
* @param fsec - Place holder for Milliseconds value
* @param nsec - Place holder for NanoSeconds value
*
* @warning
* this call is only permitted if the current interval type is Interval::DaySecond
*
*/
void GetDaySecond(int& day, int& hour, int& min, int& sec, int& fsec) const;
void GetDaySecond(int& day, int& hour, int& min, int& sec, int& nsec) const;

/**
* @brief
Expand All @@ -3352,13 +3366,13 @@ namespace ocilib
* @param hour - Hour value
* @param min - Minutes value
* @param sec - Seconds value
* @param fsec - Milliseconds value
* @param nsec - NanoSeconds value
*
* @warning
* this call is only permitted if the current interval type is Interval::DaySecond
* this call is only permitted if the current interval type is Interval::DaySecond
*
*/
void SetDaySecond(int day, int hour, int min, int sec, int fsec);
void SetDaySecond(int day, int hour, int min, int sec, int nsec);

/**
* @brief
Expand Down
16 changes: 8 additions & 8 deletions src/interval.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ boolean OcilibIntervalGetDaySecond
int *hour,
int *min,
int *sec,
int *fsec
int *nsec
)
{
ENTER_FUNC
Expand All @@ -559,13 +559,13 @@ boolean OcilibIntervalGetDaySecond
CHECK_PTR(OCI_IPC_INT, hour)
CHECK_PTR(OCI_IPC_INT, min)
CHECK_PTR(OCI_IPC_INT, sec)
CHECK_PTR(OCI_IPC_INT, fsec)
CHECK_PTR(OCI_IPC_INT, nsec)

*day = 0;
*hour = 0;
*min = 0;
*sec = 0;
*fsec = 0;
*nsec = 0;

#if OCI_VERSION_COMPILE >= OCI_9_0

Expand All @@ -575,7 +575,7 @@ boolean OcilibIntervalGetDaySecond
OCIIntervalGetDaySecond,
(dvoid *) itv->env, itv->err,
(sb4 *) day, (sb4 *) hour, (sb4 *) min,
(sb4 *) sec, (sb4 *) fsec, itv->handle
(sb4 *) sec, (sb4 *) nsec, itv->handle
)

SET_SUCCESS()
Expand All @@ -586,7 +586,7 @@ boolean OcilibIntervalGetDaySecond
OCI_NOT_USED(hour)
OCI_NOT_USED(min)
OCI_NOT_USED(sec)
OCI_NOT_USED(fsec)
OCI_NOT_USED(nsec)

#endif

Expand Down Expand Up @@ -646,7 +646,7 @@ boolean OcilibIntervalSetDaySecond
int hour,
int min,
int sec,
int fsec
int nsec
)
{
ENTER_FUNC
Expand All @@ -665,7 +665,7 @@ boolean OcilibIntervalSetDaySecond
OCIIntervalSetDaySecond,
(dvoid *) itv->env, itv->err,
(sb4) day, (sb4) hour, (sb4) min,
(sb4) sec, (sb4) fsec, itv->handle
(sb4) sec, (sb4) nsec, itv->handle
)

SET_SUCCESS()
Expand All @@ -676,7 +676,7 @@ boolean OcilibIntervalSetDaySecond
OCI_NOT_USED(hour)
OCI_NOT_USED(min)
OCI_NOT_USED(sec)
OCI_NOT_USED(fsec)
OCI_NOT_USED(nsec)

#endif

Expand Down
8 changes: 4 additions & 4 deletions src/ocilib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2841,10 +2841,10 @@ boolean OCI_API OCI_IntervalGetDaySecond
int * hour,
int * min,
int * sec,
int * fsec
int * nsec
)
{
CALL_IMPL(OcilibIntervalGetDaySecond, itv, day, hour, min, sec, fsec)
CALL_IMPL(OcilibIntervalGetDaySecond, itv, day, hour, min, sec, nsec)
}

boolean OCI_API OCI_IntervalGetYearMonth
Expand All @@ -2864,10 +2864,10 @@ boolean OCI_API OCI_IntervalSetDaySecond
int hour,
int min,
int sec,
int fsec
int nsec
)
{
CALL_IMPL(OcilibIntervalSetDaySecond, itv, day, hour, min, sec, fsec)
CALL_IMPL(OcilibIntervalSetDaySecond, itv, day, hour, min, sec, nsec)
}

boolean OCI_API OCI_IntervalSetYearMonth
Expand Down

0 comments on commit d699124

Please sign in to comment.