IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2771


Ignore:
Timestamp:
Dec 20, 2004, 7:27:44 PM (22 years ago)
Author:
eugene
Message:

added mjd funcs, clean_spaces; fixed sprintf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/imregister/base/misc.c

    r14 r2771  
    216216
    217217/**********/
     218double sec_to_mjd (unsigned long second) {
     219
     220  double mjd;
     221 
     222  mjd = second/86400.0 + 40587.0;
     223  return (mjd);
     224}
     225
     226/**********/
     227unsigned long int mjd_to_sec (double mjd) {
     228
     229  unsigned long int second;
     230
     231  second = (mjd - 40587.0)*86400;
     232  return (second);
     233}
     234
     235/**********/
    218236char *sec_to_date (unsigned long second) {
    219237 
     
    224242  second -= 3600*tz;
    225243  gmt   = gmtime (&second);
    226   sprintf (line, "%4d/%02d/%02d,%02d:%02d:%02d", 1900+gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);
     244  snprintf (line, 64, "%4d/%02d/%02d,%02d:%02d:%02d", 1900+gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);
    227245  return (line);
    228246
     
    470488  }
    471489
     490
     491/* replaces whitespace blocks with single . */
     492void clean_spaces (char *line) {
     493
     494  char *out, *in;
     495
     496  if (line == NULL) return;
     497
     498  out = in = line;
     499  while (*in) {
     500    if (whitespace(*in)) {
     501      *out = '.';
     502      out ++;
     503      in ++;
     504      while (*in && whitespace(*in)) in++;
     505    } else {
     506      *out = *in;
     507      out ++;
     508      in ++;
     509    }
     510  }
     511  *out = 0;
     512  return;
     513}
     514
     515void warn_scan (Header *header, char *field, char *format, int N, void *var) {
     516  if (!fits_scan (header, field, format, N, var)) {
     517    fprintf (stderr, "WARNING: %s not found in header\n", field);
     518  }
     519}
     520
Note: See TracChangeset for help on using the changeset viewer.