Changeset 2818 in Sophya for trunk/SophyaExt/XephemAstroLib/formats.c
- Timestamp:
- Aug 21, 2005, 12:02:40 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/XephemAstroLib/formats.c
r2643 r2818 149 149 * PREF_DATE_FORMAT preference into its components. allow the day to be a 150 150 * floating point number, 151 * actually the slashes may be anything but digits.151 * the slashes may also be spaces or colons. 152 152 * a lone component with a decimal point is considered a year. 153 153 */ … … 160 160 int *y) 161 161 { 162 double c[3]; /* the three components */162 double X,Y,Z; /* the three components */ 163 163 int n; 164 164 165 memset (c, 0, sizeof(c));166 n = sscanf (bp, "%lf%*[ ^0-9]%lf%*[^0-9]%lf", &c[0], &c[1], &c[2]);165 X = Y = Z = 0.0; 166 n = sscanf (bp, "%lf%*[/: ]%lf%*[/: ]%lf", &X, &Y, &Z); 167 167 if (n == 1 && (strchr(bp, '.') 168 || (pref == PREF_MDY && ( c[0] < 1 || c[0]> 12))169 || (pref == PREF_DMY && ( c[0] < 1 || c[0]> 31)))) {168 || (pref == PREF_MDY && (X < 1 || X > 12)) 169 || (pref == PREF_DMY && (X < 1 || X > 31)))) { 170 170 double Mjd; 171 year_mjd ( c[0], &Mjd);171 year_mjd (X, &Mjd); 172 172 mjd_cal (Mjd, m, d, y); 173 173 } else { 174 174 switch (pref) { 175 175 case PREF_MDY: 176 if (n > 0 && c[0]!= 0)177 *m = (int) c[0];178 if (n > 1 && c[1]!= 0)179 *d = c[1];180 if (n > 2 && c[2]!= 0)181 *y = (int) c[2];176 if (n > 0 && X != 0) 177 *m = (int)X; 178 if (n > 1 && Y != 0) 179 *d = Y; 180 if (n > 2 && Z != 0) 181 *y = (int)Z; 182 182 break; 183 183 case PREF_YMD: 184 if (n > 0 && c[0]!= 0)185 *y = (int) c[0];186 if (n > 1 && c[1]!= 0)187 *m = (int) c[1];188 if (n > 2 && c[2]!= 0)189 *d = c[2];184 if (n > 0 && X != 0) 185 *y = (int)X; 186 if (n > 1 && Y != 0) 187 *m = (int)Y; 188 if (n > 2 && Z != 0) 189 *d = Z; 190 190 break; 191 191 case PREF_DMY: 192 if (n > 1 && c[0]!= 0)193 *d = c[0];194 if (n > 2 && c[1]!= 0)195 *m = (int) c[1];196 if (n > 3 && c[2]!= 0)197 *y = (int) c[2];192 if (n > 0 && X != 0) 193 *d = X; 194 if (n > 1 && Y != 0) 195 *m = (int)Y; 196 if (n > 2 && Z != 0) 197 *y = (int)Z; 198 198 break; 199 199 } … … 202 202 203 203 /* For RCS Only -- Do Not Edit */ 204 static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: formats.c,v $ $Date: 2005-0 1-17 10:13:05 $ $Revision: 1.4$ $Name: not supported by cvs2svn $"};204 static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: formats.c,v $ $Date: 2005-08-21 10:02:37 $ $Revision: 1.5 $ $Name: not supported by cvs2svn $"};
Note:
See TracChangeset
for help on using the changeset viewer.