+2005-02-09 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * FdExt.subproj/NSCalendarDate+misc.m: Julian number <-> date
+ conversion methods (v4.5.144)
+
2005-02-09 Helge Hess <helge.hess@opengroupware.org>
* FdExt.subproj/NSString+misc.m: do not quote the last newline if the
}
#endif
+/* Oct. 15, 1582 */
+#define IGREG (15+31L*(10+12L*1582))
+
+- (long)julianNumber {
+ long jul;
+ int ja, jy, jm, year, month, day;
+
+ year = [self yearOfCommonEra];
+ month = [self monthOfYear];
+ day = [self dayOfMonth];
+ jy = year;
+
+ if (jy == 0)
+ return 0;
+ if (jy < 0)
+ jy++;
+
+ if (month > 2)
+ jm = month + 1;
+ else {
+ jy--;
+ jm = month + 13;
+ }
+
+ jul = (long) (floor(365.25 * jy) + floor(30.6001 * jm) + day + 1720995);
+
+ if (day + 31L * (month + 12L * year) >= IGREG) {
+ ja = (int)(0.01 * jy);
+ jul += 2 - ja + (int) (0.25 * ja);
+ }
+ return jul;
+}
+
++ (NSCalendarDate *)dateForJulianNumber:(long)_jn {
+ long ja, jalpha, jb, jc, jd, je;
+ unsigned day, month, year;
+
+ if (_jn >= IGREG) {
+ jalpha = (long)(((float) (_jn - 1867216) - 0.25) / 36524.25);
+ ja = _jn + 1 + jalpha - (long)(0.25 * jalpha);
+ } else {
+ ja = _jn;
+ }
+
+ jb = ja + 1524;
+ jc = (long)(6680.0 + ((float)(jb - 2439870) - 122.1) / 365.25);
+ jd = (long)(365 * jc + (0.25 * jc));
+ je = (long)((jb - jd) / 30.6001);
+ day = jb - jd - (long)(30.6001 * je);
+ month = je - 1;
+ if (month > 12)
+ month -= 12;
+ year = jc - 4715;
+ if (month > 2)
+ year--;
+ if (year <= 0)
+ year--;
+ return [NSCalendarDate dateWithYear:year
+ month:month
+ day:day
+ hour:12
+ minute:0
+ second:0
+ timeZone:nil];
+}
+
@end /* NSCalendarDate(misc) */
/* static linking */
);
buildSettings = {
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.140;
+ DYLIB_CURRENT_VERSION = 4.5.144;
FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks";
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
timeZone:(NSTimeZone *)_tz;
- (NSCalendarDate *)mondayOfWeek:(int)_weekNumber;
++ (NSCalendarDate *)dateForJulianNumber:(long)_jn;
+- (long)julianNumber;
+
- (NSCalendarDate *)firstDayOfMonth;
- (NSCalendarDate *)lastDayOfMonth;
- (NSCalendarDate *)mondayOfWeek;