コード例 #1
0
ファイル: timestream.c プロジェクト: n8vi/pru-dds
unsigned char *gensamples(instant *i)
{
  static unsigned char buf[8000*2];

  memset(buf, low_amp, timecode(i->second)); 
  memset(buf+timecode(i->second), 255, 8000-timecode(i->second));
  memset(buf+8000, low_amp, timecode(i->second+1));
  memset(buf+8000+timecode(i->second+1), 255, 8000-timecode(i->second+1));

  return buf+i->sampno;
}
コード例 #2
0
ファイル: strlib.cpp プロジェクト: lsauer/showimageJP2
struct timestruct startofweek(struct timestruct atime)
/* [<][>][^][v][top][bottom][index][help] */
{  /* given a time, what is the time at the start of that week? */

  extern int monthlength[];

  extern int weekbeginson;

  struct timestruct answer;
  int day;
  
  day = dayofdate(atime.date, atime.monthno, atime.year);

  answer.date = atime.date - day + weekbeginson;
           /* giving a weekbeginson-day in [date - 6, date + 6] */
  if (answer.date > atime.date)
    answer.date -= 7;
  answer.monthno = atime.monthno;
  answer.year = atime.year;

  if (answer.date <= 0) {
    answer.monthno--;
    if (answer.monthno == -1) {
      answer.monthno = 11;
      answer.year--;
    }
    answer.date = monthlength[answer.monthno] + answer.date +
      ISLEAPFEB(answer.monthno, answer.year);
  }

  answer.code = timecode(answer.date, answer.monthno, answer.year,
                         answer.hr = 0, answer.min = 0);

  return(answer);

}