Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

Date net::sf::linuxorg::pcal::engine::Engine::getPeriodStartDate ( final Date  date,
final boolean  checkMensLength 
) [inline, private]

Find the date's period start date. Returns null if no adequate date was found. This method can return the menstrual period start or the pregnancy start. This method does not check if the menstrual period is not shorter than the minimum allowed.

Parameters:
date- a date within the period
checkMensLength- if true, the menstrual period length boundaries are checked. False is useful for the future predictions, when the date can be beyond the length of a single cycle
Returns:
- the day info record

Definition at line 438 of file Engine.java.

References dateDiff(), and dateTypes.

Referenced by getDayInfoEstimated(), getDayInfoRecorded(), and getOvulationDayInfo().

                                                                                      {
            Date period_start_date = null;

            if(date == null) return period_start_date;

            Date date_pointer = startDates.lower(date);

            while(date_pointer != null) {
                  int pointer_date_type = dateTypes.get(date_pointer);

                  if((pointer_date_type == PCAL_TYPE_BIRTH) || 
                              (pointer_date_type == PCAL_TYPE_PREGNANCY_INT)) {
                        // the last period has ended, the new period was not started
                        break;
                  } else 
                        if(pointer_date_type == PCAL_TYPE_MENS) {
                              int day_number = dateDiff(date_pointer, date);
                              if(checkMensLength) {
                                    if(day_number < enginePreferences.regularMaxLength) {
                                          period_start_date = date_pointer;
                                    } 
                              } else {
                                    period_start_date = date_pointer;
                              }
                              break;
                        }
                  if(pointer_date_type == PCAL_TYPE_PREGNANCY) {
                        int day_number = dateDiff(date_pointer, date);
                        if(checkMensLength) {
                              if(day_number < MAX_PREGNANCY_DAYS) {
                                    period_start_date = date_pointer;
                              }                             
                        } else {
                              period_start_date = date_pointer;
                        }
                        break;
                  }
                  else {
                        // lets look for the earlier recorded date
                        date_pointer = startDates.lower(date_pointer);
                  }
            }
            return period_start_date;
      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index