~ubuntu-branches/ubuntu/wily/gnustep-base/wily

« back to all changes in this revision

Viewing changes to Source/NSCalendarDate.m

  • Committer: Package Import Robot
  • Author(s): Yavor Doganov
  • Date: 2011-09-15 12:31:15 UTC
  • mfrom: (1.2.11 upstream) (8.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20110915123115-rmvsia9z0211izvq
Tags: 1.22.1-1
* New upstream release:
  + Fixes implicit declaration of function (Closes: #629216).
* debian/rules (v_make): Set to 2.6.1.
  (install-common): Do not delete non-existent .swp file.
* debian/control.m4 (Build-Depends): Remove gobjc; gnustep-make now
  depends on it.
  (libgnustep-base-dev) <Depends>: Likewise.
  (Suggests): Remove; completely pointless.
* debian/control: Regenerate.
* debian/patches/avoid-nsl-linkage.patch: Refresh.
* debian/patches/autoreconf.patch: Regenerate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
   Boston, MA 02111 USA.
26
26
 
27
27
   <title>NSCalendarDate class reference</title>
28
 
   $Date: 2010-08-21 09:03:32 +0100 (Sat, 21 Aug 2010) $ $Revision: 31191 $
 
28
   $Date: 2011-03-16 13:17:48 +0000 (Wed, 16 Mar 2011) $ $Revision: 32605 $
29
29
   */
30
30
 
31
31
#import "common.h"
284
284
 * Returns the current time (seconds since reference date) as an NSTimeInterval.
285
285
 */
286
286
NSTimeInterval
287
 
GSTimeNow(void)
 
287
GSPrivateTimeNow(void)
288
288
{
289
289
  NSTimeInterval t;
290
290
#if !defined(__MINGW__)
321
321
            diff, ctime(&now));
322
322
          /* Get time again ... should be OK now.
323
323
           */
324
 
          t = GSTimeNow();
 
324
          t = GSPrivateTimeNow();
325
325
        }
326
326
    }
327
327
}
495
495
 */
496
496
- (id) initWithString: (NSString *)description
497
497
{
498
 
  // +++ What is the locale?
499
498
  return [self initWithString: description
500
499
               calendarFormat: cformat
501
500
                       locale: nil];
509
508
- (id) initWithString: (NSString *)description
510
509
       calendarFormat: (NSString *)format
511
510
{
512
 
  // ++ What is the locale?
513
511
  return [self initWithString: description
514
512
               calendarFormat: format
515
513
                       locale: nil];
1107
1105
 
1108
1106
                  case 'd': // fall through
1109
1107
                  case 'e':
1110
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 2, &error);
 
1108
                    sourceIdx
 
1109
                      += getDigits(&source[sourceIdx], tmpStr, 2, &error);
1111
1110
                    day = atoi(tmpStr);
1112
1111
                    had |= hadD;
1113
1112
                    if (error == NO && day < 1)
1118
1117
                    break;
1119
1118
 
1120
1119
                  case 'F':
1121
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 3, &error);
 
1120
                    sourceIdx
 
1121
                      += getDigits(&source[sourceIdx], tmpStr, 3, &error);
1122
1122
                    milliseconds = atoi(tmpStr);
1123
1123
                    break;
1124
1124
 
1134
1134
                  case 'I': // fall through
1135
1135
                    twelveHrClock = YES;
1136
1136
                  case 'H':
1137
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 2, &error);
 
1137
                    sourceIdx
 
1138
                      += getDigits(&source[sourceIdx], tmpStr, 2, &error);
1138
1139
                    hour = atoi(tmpStr);
1139
1140
                    had |= hadh;
1140
1141
                    break;
1141
1142
 
1142
1143
                  case 'j':
1143
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 3, &error);
 
1144
                    sourceIdx
 
1145
                      += getDigits(&source[sourceIdx], tmpStr, 3, &error);
1144
1146
                    day = atoi(tmpStr);
1145
1147
                    had |= hadD;
1146
1148
                    break;
1147
1149
 
1148
1150
                  case 'm':
1149
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 2, &error);
 
1151
                    sourceIdx
 
1152
                      += getDigits(&source[sourceIdx], tmpStr, 2, &error);
1150
1153
                    month = atoi(tmpStr);
1151
1154
                    had |= hadM;
1152
1155
                    if (error == NO && month < 1)
1157
1160
                    break;
1158
1161
 
1159
1162
                  case 'M':
1160
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 2, &error);
 
1163
                    sourceIdx
 
1164
                      += getDigits(&source[sourceIdx], tmpStr, 2, &error);
1161
1165
                    min = atoi(tmpStr);
1162
1166
                    had |= hadm;
1163
1167
                    break;
1186
1190
                       * The time addition is handled below because this
1187
1191
                       * indicator only modifies the time on a 12hour clock.
1188
1192
                       */
1189
 
                      if ([[amPMNames objectAtIndex: 0] isEqual:currAMPM])
 
1193
                      if ([currAMPM caseInsensitiveCompare:
 
1194
                        [amPMNames objectAtIndex: 0]] == NSOrderedSame)
1190
1195
                        {
1191
1196
                          ampm = YES;
1192
1197
                          isPM = NO;
1193
1198
                        }
1194
 
                      else if ([[amPMNames objectAtIndex: 1] isEqual:currAMPM])
 
1199
                      else if ([currAMPM caseInsensitiveCompare:
 
1200
                        [amPMNames objectAtIndex: 1]] == NSOrderedSame)
1195
1201
                        {
1196
1202
                          ampm = YES;
1197
1203
                          isPM = YES;
1200
1206
                    break;
1201
1207
 
1202
1208
                  case 'S':
1203
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 2, &error);
 
1209
                    sourceIdx
 
1210
                      += getDigits(&source[sourceIdx], tmpStr, 2, &error);
1204
1211
                    sec = atoi(tmpStr);
1205
1212
                    had |= hads;
1206
1213
                    break;
1207
1214
 
1208
1215
                  case 'w':
1209
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 1, &error);
 
1216
                    sourceIdx
 
1217
                      += getDigits(&source[sourceIdx], tmpStr, 1, &error);
1210
1218
                    dayOfWeek = atoi(tmpStr);
1211
1219
                    had |= hadw;
1212
1220
                    break;
1214
1222
                  case 'W': // Fall through
1215
1223
                    weekStartsMonday = 1;
1216
1224
                  case 'U':
1217
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 1, &error);
 
1225
                    sourceIdx
 
1226
                      += getDigits(&source[sourceIdx], tmpStr, 1, &error);
1218
1227
                    julianWeeks = atoi(tmpStr);
1219
1228
                    break;
1220
1229
 
1225
1234
                    //  break;
1226
1235
 
1227
1236
                  case 'y':
1228
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 2, &error);
 
1237
                    sourceIdx
 
1238
                      += getDigits(&source[sourceIdx], tmpStr, 2, &error);
1229
1239
                    year = atoi(tmpStr);
1230
1240
                    if (year >= 70)
1231
1241
                      {
1239
1249
                    break;
1240
1250
 
1241
1251
                  case 'Y':
1242
 
                    sourceIdx += getDigits(&source[sourceIdx], tmpStr, 4, &error);
 
1252
                    sourceIdx
 
1253
                      += getDigits(&source[sourceIdx], tmpStr, 4, &error);
1243
1254
                    year = atoi(tmpStr);
1244
1255
                    had |= hadY;
1245
1256
                    break;
1859
1870
  char  cbuf[MAX_FLD_WIDTH + 1];
1860
1871
  int   idx = 0;
1861
1872
 
1862
 
  sprintf((char*)cbuf, fldfmt, v);
 
1873
  snprintf((char*)cbuf, sizeof(cbuf), fldfmt, v);
1863
1874
  Grow(info, strlen((char*)cbuf));
1864
1875
  while (cbuf[idx] != '\0')
1865
1876
    {
1976
1987
                v = info->yd;
1977
1988
                if (ycent)
1978
1989
                  {
1979
 
                    if (fmtlen == 1) // no format width specified; supply default
 
1990
                    if (fmtlen == 1)
1980
1991
                      {
 
1992
                        // no format width specified; supply default
1981
1993
                        fldfmt[fmtlen++] = '0';
1982
1994
                        fldfmt[fmtlen++] = '4';
1983
1995
                      }
1986
1998
                  {
1987
1999
                    if (v < 0) v = -v;
1988
2000
                    v = v % 100;
1989
 
                    if (fmtlen == 1) // no format width specified; supply default
 
2001
                    if (fmtlen == 1)
1990
2002
                      {
 
2003
                        // no format width specified; supply default
1991
2004
                        fldfmt[fmtlen++] = '0';
1992
2005
                        fldfmt[fmtlen++] = '2';
1993
2006
                      }
1994
2007
                  }
1995
2008
                  fldfmt[fmtlen++] = 'd';
1996
 
                  fldfmt[fmtlen++] = 0;
 
2009
                  fldfmt[fmtlen] = 0;
1997
2010
                  outputValueWithFormat(v, fldfmt, info);
1998
2011
                break;
1999
2012
 
2030
2043
                  {
2031
2044
                    v = info->md;
2032
2045
                    v = v % 100;
2033
 
                    if (fmtlen == 1) // no format width specified; supply default
 
2046
                    if (fmtlen == 1)
2034
2047
                      {
 
2048
                        // no format width specified; supply default
2035
2049
                        fldfmt[fmtlen++] = '0';
2036
2050
                        fldfmt[fmtlen++] = '2';
2037
2051
                      }
2038
2052
                    fldfmt[fmtlen++] = 'd';
2039
 
                    fldfmt[fmtlen++] = 0;
 
2053
                    fldfmt[fmtlen] = 0;
2040
2054
                    outputValueWithFormat(v, fldfmt, info);
2041
2055
                  }
2042
2056
                break;
2044
2058
              case 'd':         // day of month with leading zero
2045
2059
                v = info->dom;
2046
2060
                v = v % 100;
2047
 
                    if (fmtlen == 1) // no format width specified; supply default
2048
 
                      {
2049
 
                        fldfmt[fmtlen++] = '0';
2050
 
                        fldfmt[fmtlen++] = '2';
2051
 
                      }
2052
 
                    fldfmt[fmtlen++] = 'd';
2053
 
                    fldfmt[fmtlen++] = 0;
2054
 
                    outputValueWithFormat(v, fldfmt, info);
 
2061
                if (fmtlen == 1) // no format width specified; supply default
 
2062
                  {
 
2063
                    fldfmt[fmtlen++] = '0';
 
2064
                    fldfmt[fmtlen++] = '2';
 
2065
                  }
 
2066
                fldfmt[fmtlen++] = 'd';
 
2067
                fldfmt[fmtlen] = 0;
 
2068
                outputValueWithFormat(v, fldfmt, info);
2055
2069
                break;
2056
2070
 
2057
2071
              case 'e':         // day of month with leading space
2058
2072
                v = info->dom;
2059
2073
                v = v % 100;
2060
 
                    if (fmtlen == 1) // no format width specified; supply default
2061
 
                      {
2062
 
                        fldfmt[fmtlen++] = '1'; // no leading space, just like Cocoa
2063
 
                      }
2064
 
                    fldfmt[fmtlen++] = 'd';
2065
 
                    fldfmt[fmtlen++] = 0;
2066
 
                    outputValueWithFormat(v, fldfmt, info);
 
2074
                if (fmtlen == 1) // no format width specified; supply default
 
2075
                  {
 
2076
                    fldfmt[fmtlen++] = '1'; // no leading space, just like Cocoa
 
2077
                  }
 
2078
                fldfmt[fmtlen++] = 'd';
 
2079
                fldfmt[fmtlen] = 0;
 
2080
                outputValueWithFormat(v, fldfmt, info);
2067
2081
                break;
2068
2082
 
2069
2083
              case 'F':         // milliseconds
2083
2097
                    fldfmt[fmtlen++] = '3';
2084
2098
                  }
2085
2099
                fldfmt[fmtlen++] = 'd';
2086
 
                fldfmt[fmtlen++] = 0;
 
2100
                fldfmt[fmtlen] = 0;
2087
2101
                outputValueWithFormat(v, fldfmt, info);
2088
2102
                break;
2089
2103
 
2095
2109
                    fldfmt[fmtlen++] = '3';
2096
2110
                  }
2097
2111
                fldfmt[fmtlen++] = 'd';
2098
 
                fldfmt[fmtlen++] = 0;
 
2112
                fldfmt[fmtlen] = 0;
2099
2113
                outputValueWithFormat(v, fldfmt, info);
2100
2114
                break;
2101
2115
 
2132
2146
                    }
2133
2147
                  if (dtag == NO)
2134
2148
                    {
2135
 
                      if (fmtlen == 1) // no format width specified; supply default
 
2149
                      if (fmtlen == 1)
2136
2150
                        {
 
2151
                          // no format width specified; supply default
2137
2152
                          fldfmt[fmtlen++] = '1';
2138
 
                          }
 
2153
                        }
2139
2154
                      fldfmt[fmtlen++] = 'd';
2140
 
                      fldfmt[fmtlen++] = 0;
 
2155
                      fldfmt[fmtlen] = 0;
2141
2156
                      outputValueWithFormat(v, fldfmt, info);
2142
2157
                    }
2143
2158
                }
2174
2189
 
2175
2190
                  }
2176
2191
                fldfmt[fmtlen++] = 'd';
2177
 
                fldfmt[fmtlen++] = 0;
 
2192
                fldfmt[fmtlen] = 0;
2178
2193
                if (GSPrivateDefaultsFlag(GSMacOSXCompatible)
2179
2194
                    && hspc == YES)
2180
2195
                  {
2196
2211
                    fldfmt[fmtlen++] = '2';
2197
2212
                  }
2198
2213
                fldfmt[fmtlen++] = 'd';
2199
 
                fldfmt[fmtlen++] = 0;
 
2214
                fldfmt[fmtlen] = 0;
2200
2215
                outputValueWithFormat(v, fldfmt, info);
2201
2216
                break;
2202
2217
 
2209
2224
                    fldfmt[fmtlen++] = '2';
2210
2225
                  }
2211
2226
                fldfmt[fmtlen++] = 'd';
2212
 
                fldfmt[fmtlen++] = 0;
 
2227
                fldfmt[fmtlen] = 0;
2213
2228
                outputValueWithFormat(v, fldfmt, info);
2214
2229
                break;
2215
2230
 
2455
2470
 * the specified locale dictionary.<br />
2456
2471
 * Calls -descriptionWithCalendarFormat:locale: to do this.
2457
2472
 */
2458
 
- (NSString*) descriptionWithLocale: (NSDictionary *)locale
 
2473
- (NSString*) descriptionWithLocale: (id)locale
2459
2474
{
2460
2475
  return [self descriptionWithCalendarFormat: _calendar_format locale: locale];
2461
2476
}