X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata-out.c;h=7b79a26f4249910eb9ecb623d3514eea28d60cd6;hb=2013acbcc3afa3f974de6ad335248e97a9c7b965;hp=de9bfad31a42afb2cd96294ee2edbdcce65848e8;hpb=205ac3afa4c2b19c85819d8695abf3975bb11807;p=pspp diff --git a/src/data-out.c b/src/data-out.c index de9bfad31a..7b79a26f42 100644 --- a/src/data-out.c +++ b/src/data-out.c @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include "error.h" @@ -24,9 +24,9 @@ #include #include #include +#include "calendar.h" #include "error.h" #include "format.h" -#include "julcal/julcal.h" #include "magic.h" #include "misc.h" #include "misc.h" @@ -103,9 +103,11 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) case FMT_A: assert (0); + abort (); case FMT_AHEX: assert (0); + abort (); case FMT_IB: ok = convert_IB (s, fp, number); @@ -159,6 +161,7 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) default: assert (0); + abort (); } } else @@ -178,6 +181,7 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) default: assert (0); + abort (); } } @@ -748,9 +752,13 @@ convert_date (char *dst, const struct fmt_spec *fp, double number) }; char buf[64] = {0}; + int ofs = number / 86400.; int month, day, year; - julian_to_calendar (number / 86400., &year, &month, &day); + if (ofs < 1) + return 0; + + calendar_offset_to_gregorian (ofs, &year, &month, &day); switch (fp->type) { case FMT_DATE: @@ -779,15 +787,13 @@ convert_date (char *dst, const struct fmt_spec *fp, double number) break; case FMT_JDATE: { - int yday = (number / 86400.) - calendar_to_julian (year, 1, 1) + 1; + int yday = calendar_offset_to_yday (ofs); - if (fp->w >= 7) - { - if (year4 (year)) - sprintf (buf, "%04d%03d", year, yday); - } - else - sprintf (buf, "%02d%03d", year % 100, yday); + if (fp->w < 7) + sprintf (buf, "%02d%03d", year % 100, yday); + else if (year4 (year)) + sprintf (buf, "%04d%03d", year, yday); + else break; } case FMT_QYR: @@ -804,7 +810,7 @@ convert_date (char *dst, const struct fmt_spec *fp, double number) break; case FMT_WKYR: { - int yday = (number / 86400.) - calendar_to_julian (year, 1, 1) + 1; + int yday = calendar_offset_to_yday (ofs); if (fp->w >= 10) sprintf (buf, "%02d WK% 04d", (yday - 1) / 7 + 1, year);