/[pspp]/pspp/src/data-out.c
ViewVC logotype

Diff of /pspp/src/data-out.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by blp, Fri Mar 26 09:03:03 2004 UTC revision 1.12 by blp, Tue Mar 1 08:16:15 2005 UTC
# Line 24  Line 24 
24  #include <float.h>  #include <float.h>
25  #include <stdlib.h>  #include <stdlib.h>
26  #include <time.h>  #include <time.h>
27    #include "calendar.h"
28  #include "error.h"  #include "error.h"
29  #include "format.h"  #include "format.h"
 #include "julcal/julcal.h"  
30  #include "magic.h"  #include "magic.h"
31  #include "misc.h"  #include "misc.h"
32  #include "misc.h"  #include "misc.h"
# Line 752  convert_date (char *dst, const struct fm Line 752  convert_date (char *dst, const struct fm
752      };      };
753    
754    char buf[64] = {0};    char buf[64] = {0};
755      int ofs = number / 86400.;
756    int month, day, year;    int month, day, year;
757    
758    julian_to_calendar (number / 86400., &year, &month, &day);    if (ofs < 1)
759        return 0;
760    
761      calendar_offset_to_gregorian (ofs, &year, &month, &day);
762    switch (fp->type)    switch (fp->type)
763      {      {
764      case FMT_DATE:      case FMT_DATE:
# Line 783  convert_date (char *dst, const struct fm Line 787  convert_date (char *dst, const struct fm
787        break;        break;
788      case FMT_JDATE:      case FMT_JDATE:
789        {        {
790          int yday = (number / 86400.) - calendar_to_julian (year, 1, 1) + 1;          int yday = calendar_offset_to_yday (ofs);
791                    
792          if (fp->w >= 7)          if (fp->w < 7)
793            {            sprintf (buf, "%02d%03d", year % 100, yday);
794              if (year4 (year))          else if (year4 (year))
795                sprintf (buf, "%04d%03d", year, yday);            sprintf (buf, "%04d%03d", year, yday);
796            }          else
         else  
           sprintf (buf, "%02d%03d", year % 100, yday);  
797          break;          break;
798        }        }
799      case FMT_QYR:      case FMT_QYR:
# Line 808  convert_date (char *dst, const struct fm Line 810  convert_date (char *dst, const struct fm
810        break;        break;
811      case FMT_WKYR:      case FMT_WKYR:
812        {        {
813          int yday = (number / 86400.) - calendar_to_julian (year, 1, 1) + 1;          int yday = calendar_offset_to_yday (ofs);
814                    
815          if (fp->w >= 10)          if (fp->w >= 10)
816            sprintf (buf, "%02d WK% 04d", (yday - 1) / 7 + 1, year);            sprintf (buf, "%02d WK% 04d", (yday - 1) / 7 + 1, year);

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26