/* Implementation of the DATE_AND_TIME intrinsic.
- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2003-2019 Free Software Foundation, Inc.
Contributed by Steven Bosscher.
This file is part of the GNU Fortran runtime library (libgfortran).
#include "libgfortran.h"
#include <string.h>
#include <assert.h>
-#include <stdlib.h>
#include "time_1.h"
GFC_INTEGER_4 values[VALUES_SIZE];
GFC_REAL_4 temp1, temp2;
- /* Make the INTEGER*4 array for passing to date_and_time. */
- gfc_array_i4 *avalues = xmalloc (sizeof (gfc_array_i4));
+ /* Make the INTEGER*4 array for passing to date_and_time, with enough space
+ for a rank-one array. */
+ gfc_array_i4 *avalues = xmalloc (sizeof (gfc_array_i4)
+ + sizeof (descriptor_dimension));
avalues->base_addr = &values[0];
- GFC_DESCRIPTOR_DTYPE (avalues) = ((BT_REAL << GFC_DTYPE_TYPE_SHIFT)
- & GFC_DTYPE_TYPE_MASK) +
- (4 << GFC_DTYPE_SIZE_SHIFT);
-
+ GFC_DESCRIPTOR_DTYPE (avalues).type = BT_REAL;
+ GFC_DESCRIPTOR_DTYPE (avalues).elem_len = 4;
+ GFC_DESCRIPTOR_DTYPE (avalues).rank = 1;
GFC_DIMENSION_SET(avalues->dim[0], 0, 7, 1);
date_and_time (NULL, NULL, NULL, avalues, 0, 0, 0);
1. Seconds after the minute, range 0-59 or 0-61 to allow for leap seconds
2. Minutes after the hour, range 0-59
3. Hours past midnight, range 0-23
- 4. Day of month, range 0-31
+ 4. Day of month, range 1-31
5. Number of months since January, range 0-11
6. Years since 1900
7. Number of days since Sunday, range 0-6
- 8. Days since January 1
+ 8. Days since January 1, range 0-365
9. Daylight savings indicator: positive if daylight savings is in effect,
zero if not, and negative if the information isn't available. */
1. Seconds after the minute, range 0-59 or 0-61 to allow for leap seconds
2. Minutes after the hour, range 0-59
3. Hours past midnight, range 0-23
- 4. Day of month, range 0-31
+ 4. Day of month, range 1-31
5. Number of months since January, range 0-11
6. Years since 1900
7. Number of days since Sunday, range 0-6
- 8. Days since January 1
+ 8. Days since January 1, range 0-365
9. Daylight savings indicator: positive if daylight savings is in effect,
zero if not, and negative if the information isn't available. */