Changeset 50

Show
Ignore:
Timestamp:
03/27/06 14:38:52 (6 years ago)
Author:
PeyloW
Message:

Streamlined function names allot

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/date.d

    r49 r50  
    2828 * Gregorian dates.  
    2929 * 
    30  * Using the asumption that a year is 365.2425 days, correct dates can be  
    31  * calculated for well beyond 5 million years into the future. Dates before 
    32  * 1900 are to complex to warrant for a date handler. 
     30 * The filosophy of this module is that dates, times and durations are discrete 
     31 * values no more complex than integers and floats.  
     32 * 
     33 * Code for parsing dates, times and durations have been taken and rewritten, 
     34 * from the PostgreSQL C source code. As such they are very complete and 
     35 * competent. A huge thanks to the PostgreSQL hackers!  
    3336 * 
    3437 * Authors: Fredrik Olsson <peylow@treyst.se> 
    3538 * Standards: Conforms to ISO 8601 
     39 * Bugs: Does not handle the special case of compact ISO 8601 times (HHMMSS). 
     40 * Date: 2006-03-27 
     41 *  
    3642 */ 
    3743 
     
    202208 */ 
    203209public int weeksInYear(int year) { 
    204   return datePart(toDate(year, 12, 31), DatePart.WEEK); 
     210  return extract(toDate(year, 12, 31), DatePart.WEEK); 
    205211} 
    206212 
     
    254260 * Returns: The d_date date as a string. 
    255261 */ 
    256 public char[] dateToString(d_date date, char[] format = ISO_FORMAT_DATE) { 
     262public char[] toString(d_date date, char[] format = ISO_FORMAT_DATE) { 
    257263  assert(format == ISO_FORMAT_DATE); 
    258264  int year, month, day; 
     
    452458 * Returns: The datepart of a date. 
    453459 */ 
    454 public int datePart(d_date date, DatePart datePart) { 
     460public int extract(d_date date, DatePart datePart) { 
    455461  if (datePart != DatePart.WEEK && datePart != DatePart.WEEKDAY) { 
    456462    if (datePart == DatePart.YEARDAY) { 
     
    477483          return day; 
    478484        default: 
    479           throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     485          throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    480486              " is an invalid date part"); 
    481487      } 
     
    490496} 
    491497unittest { 
    492   // Also tests incDate(DatePart, int) and incDate(duration) 
     498  // Also tests increment(DatePart, int) and increment(duration) 
    493499  // And toDuration(int, int, int) 
    494500  d_date d = toDate("2006-03-10"); 
    495   assert(datePart(d, DatePart.YEARDAY) == 69); 
    496   d = incDate(d, DatePart.WEEK, 1); // 2006-03-17 
    497   assert(datePart(d, DatePart.WEEKDAY) == 4); 
    498   d = incDate(d, DatePart.MONTH, 1); // 2006-04-17 
    499   assert(datePart(d, DatePart.MONTH) == 4); 
    500   d = incDate(d, DatePart.YEAR, 2); // 2008-04-17 
    501   assert(datePart(d, DatePart.DAY) == 17); 
    502   d = incDate(d, toDateDuration(-1, 1, -6)); // 2007-05-11 
    503   assert(datePart(d, DatePart.DECADE) == 200); 
    504   assert(datePart(d, DatePart.YEAR) == 2007); 
    505   assert(datePart(d, DatePart.QUARTER) == 2); 
    506   assert(datePart(d, DatePart.WEEK) == 19); 
    507   d = incDate(d, toDateDuration(-4100, 14, 200)); // 2092-01-07 BCE 
    508   assert(datePart(d, DatePart.MILLENIA) == -2);  
     501  assert(extract(d, DatePart.YEARDAY) == 69); 
     502  d = increment(d, DatePart.WEEK, 1); // 2006-03-17 
     503  assert(extract(d, DatePart.WEEKDAY) == 4); 
     504  d = increment(d, DatePart.MONTH, 1); // 2006-04-17 
     505  assert(extract(d, DatePart.MONTH) == 4); 
     506  d = increment(d, DatePart.YEAR, 2); // 2008-04-17 
     507  assert(extract(d, DatePart.DAY) == 17); 
     508  d = increment(d, toDateDuration(-1, 1, -6)); // 2007-05-11 
     509  assert(extract(d, DatePart.DECADE) == 200); 
     510  assert(extract(d, DatePart.YEAR) == 2007); 
     511  assert(extract(d, DatePart.QUARTER) == 2); 
     512  assert(extract(d, DatePart.WEEK) == 19); 
     513  d = increment(d, toDateDuration(-4100, 14, 200)); // 2092-01-07 BCE 
     514  assert(extract(d, DatePart.MILLENIA) == -2);  
    509515} 
    510516 
     
    520526 * Returns: A d_date date. 
    521527 */ 
    522 public d_date incDate(d_date date, DatePart datePart, int count) { 
     528public d_date increment(d_date date, DatePart datePart, int count) { 
    523529  switch (datePart) { 
    524530    case DatePart.MILLENIA: 
     
    537543      return date + count; 
    538544    default: 
    539       throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     545      throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    540546          " is an invalid date part"); 
    541547  } 
     
    552558 * Returns: A d_date date. 
    553559 */ 
    554 public d_date incDate(d_date date, d_duration duration) { 
     560public d_date increment(d_date date, d_duration duration) { 
    555561  return addMonthsToDate(date, duration.months) + cast(int)duration.daysAndTime; 
    556562} 
     
    566572 * Returns: A d_date date. 
    567573 */ 
    568 public d_date truncDate(d_date date, DatePart datePart) { 
     574public d_date truncate(d_date date, DatePart datePart) { 
    569575  int year, month, day; 
    570576  splitDate(date, year, month, day); 
     
    592598      return date - weekDayOfDate(date); 
    593599    default: 
    594       throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     600      throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    595601          " is an invalid date part"); 
    596602  } 
     
    599605unittest { 
    600606  d_date d = toDate(2026, 10, 28); 
    601   assert(truncDate(d, DatePart.MILLENIA) == toDate(2000, 1, 1)); 
    602   assert(truncDate(d, DatePart.DECADE) == toDate(2020, 1, 1)); 
    603   assert(truncDate(d, DatePart.YEAR) == toDate(2026, 1, 1)); 
    604   assert(truncDate(d, DatePart.QUARTER) == toDate(2026, 10, 1)); 
    605   assert(truncDate(d, DatePart.MONTH) == toDate(2026, 10, 1)); 
    606   assert(truncDate(d, DatePart.WEEK) == toDate(2026, 10, 26));   
     607  assert(truncate(d, DatePart.MILLENIA) == toDate(2000, 1, 1)); 
     608  assert(truncate(d, DatePart.DECADE) == toDate(2020, 1, 1)); 
     609  assert(truncate(d, DatePart.YEAR) == toDate(2026, 1, 1)); 
     610  assert(truncate(d, DatePart.QUARTER) == toDate(2026, 10, 1)); 
     611  assert(truncate(d, DatePart.MONTH) == toDate(2026, 10, 1)); 
     612  assert(truncate(d, DatePart.WEEK) == toDate(2026, 10, 26));   
    607613} 
    608614 
     
    643649 * Returns: The d_time time as a string. 
    644650 */ 
    645 public char[] timeToString(d_time time, char[] format = ISO_FORMAT_TIME) { 
     651public char[] toString(d_time time, char[] format = ISO_FORMAT_TIME) { 
    646652  int hour, minute, second, millisecond; 
    647653 
     
    684690} 
    685691unittest { 
    686   // Also tests toTime(int, int, int) and timeToString(), splitTime() 
     692  // Also tests toTime(int, int, int) and toString(), splitTime() 
    687693  d_time t = toTime("12:01:02"); 
    688   assert(timeToString(t) == "12:01:02"); 
     694  assert(toString(t) == "12:01:02"); 
    689695  assert(t == toTime(12, 1, 2)); 
    690696// TODO: Allow for compact ISO times. 
     
    751757 * Returns: The datepart of a d_time time. 
    752758 */ 
    753 public int datePart(d_time time, DatePart datePart) { 
     759public int extract(d_time time, DatePart datePart) { 
    754760  time = normTime(time); 
    755761  switch (datePart) { 
     
    763769      return cast(int)time % 1000;   
    764770    default: 
    765       throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     771      throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    766772          " is an invalid date part"); 
    767773  } 
    768774} 
    769775unittest { 
    770   // Also tests toTimeDuration(), incTime(DatePart, int), and incTime(duration) 
     776  // Also tests toTimeDuration(), increment(DatePart, int), and increment(duration) 
    771777  d_time t = toTime(1, 2, 3, 100); // 01:02:03.100 
    772   assert(datePart(t, DatePart.MILLISECOND) == 100); 
    773   t = incTime(t, DatePart.MINUTE, 125); // 03:07:03.100 
    774   assert(datePart(t, DatePart.MINUTE) == 7); 
    775   t = incTime(t, toTimeDuration(-12, 20, 57, 50)); // 15:28:00.150 
    776   assert(datePart(t, DatePart.HOUR) == 15); 
    777   assert(datePart(t, DatePart.SECOND) == 0); 
     778  assert(extract(t, DatePart.MILLISECOND) == 100); 
     779  t = increment(t, DatePart.MINUTE, 125); // 03:07:03.100 
     780  assert(extract(t, DatePart.MINUTE) == 7); 
     781  t = increment(t, toTimeDuration(-12, 20, 57, 50)); // 15:28:00.150 
     782  assert(extract(t, DatePart.HOUR) == 15); 
     783  assert(extract(t, DatePart.SECOND) == 0); 
    778784} 
    779785 
     
    788794 * Returns: A d_time time. 
    789795 */ 
    790 public d_time truncTime(d_time time, DatePart datePart) { 
     796public d_time truncate(d_time time, DatePart datePart) { 
    791797  time = normTime(time); 
    792798  switch (datePart) { 
     
    798804      return cast(d_time)(cast(int)(time / MSEC_PER_SEC) * MSEC_PER_SEC); 
    799805    default: 
    800       throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     806      throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    801807          " is an invalid date part"); 
    802808  } 
     
    804810unittest { 
    805811  d_time t = toTime(12, 13, 14, 15); 
    806   assert(truncTime(t, DatePart.SECOND) == toTime("12:13:14")); 
    807   assert(truncTime(t, DatePart.MINUTE) == toTime("12:13:00")); 
    808   assert(truncTime(t, DatePart.HOUR) == toTime("12:00:00")); 
     812  assert(truncate(t, DatePart.SECOND) == toTime("12:13:14")); 
     813  assert(truncate(t, DatePart.MINUTE) == toTime("12:13:00")); 
     814  assert(truncate(t, DatePart.HOUR) == toTime("12:00:00")); 
    809815} 
    810816 
     
    820826 * Returns: A d_time time. 
    821827 */ 
    822 public d_time incTime(d_time time, DatePart datePart, int count) { 
     828public d_time increment(d_time time, DatePart datePart, int count) { 
    823829  switch (datePart) { 
    824830    case DatePart.HOUR: 
     
    835841      break; 
    836842    default: 
    837       throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     843      throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    838844          " is an invalid date part"); 
    839845  } 
     
    851857 * Returns: A d_time time. 
    852858 */ 
    853 public d_time incTime(d_time time, d_duration duration) { 
     859public d_time increment(d_time time, d_duration duration) { 
    854860  time += cast(d_time)(duration.daysAndTime * MSEC_PER_DAY) % 
    855861      MSEC_PER_DAY; 
     
    867873 * Returns: The d_timestamp time as a string. 
    868874 */ 
    869 public char[] timeStampToString(d_timestamp timestamp,  
     875public char[] toString(d_timestamp timestamp,  
    870876    char[] format = ISO_FORMAT_TIMESTAMP) { 
    871877  assert(format == ISO_FORMAT_TIMESTAMP); 
    872878   
    873   return dateToString(dateOfTimeStamp(timestamp), format[0..8]) ~ " " ~ 
    874          timeToString(timeOfTimeStamp(timestamp), format[9..$]); 
     879  return toString(dateOfTimeStamp(timestamp), format[0..8]) ~ " " ~ 
     880         toString(timeOfTimeStamp(timestamp), format[9..$]); 
    875881} 
    876882  
     
    910916unittest { 
    911917  // Also tests toTimeStamp(int, int...), toTimeStamp(date, time), 
    912   // toTimeStamp(int), timeStampToString(), and splitTimeStamp() 
     918  // toTimeStamp(int), toString(), and splitTimeStamp() 
    913919  d_timestamp ts = toTimeStamp("2006-03-19 11:42:00"); 
    914920  assert(ts == toTimeStamp(toDate("2006-03-19"), toTime("11:42:00"))); 
    915   assert(timeStampToString(toTimeStamp(0)) == "1970-01-01 00:00:00"); 
     921  assert(toString(toTimeStamp(0)) == "1970-01-01 00:00:00"); 
    916922  d_date d; 
    917923  d_time t; 
     
    10061012 * Returns: The datepart of a date/time. 
    10071013 */ 
    1008 public int datePart(d_timestamp timestamp, DatePart aDatePart) { 
     1014public int extract(d_timestamp timestamp, DatePart aDatePart) { 
    10091015  if (aDatePart == DatePart.EPOCH) { 
    10101016    return cast(int)((cast(double)timestamp + DATE_UNIX_EPOCH_OFFSET) *  
    10111017        SEC_PER_DAY); 
    10121018  } else if (aDatePart < DatePart.HOUR) { 
    1013     return datePart(dateOfTimeStamp(timestamp), aDatePart); 
     1019    return extract(dateOfTimeStamp(timestamp), aDatePart); 
    10141020  } else { 
    1015     return datePart(timeOfTimeStamp(timestamp), aDatePart);   
     1021    return extract(timeOfTimeStamp(timestamp), aDatePart);   
    10161022  } 
    10171023} 
    10181024unittest { 
    10191025  d_timestamp ts = toTimeStamp("2006-01-01 00:00:00"); 
    1020   ts = incTimeStamp(ts, toDuration(1, 2, 3, 4, 5, 6, 7)); // 2006-03-04 04:05:06.007 
    1021   assert(datePart(ts, DatePart.SECOND) == 6); 
    1022   ts = incTimeStamp(ts, DatePart.SECOND, -200); // 2006-03-04 04:01:46.007  
    1023   assert(datePart(ts, DatePart.MINUTE) == 1); 
    1024   ts = incTimeStamp(ts, DatePart.HOUR, 50); // 2006-03-06 06:05:06.007 
    1025   assert(datePart(ts, DatePart.HOUR) == 6); 
    1026   ts = incTimeStamp(ts, DatePart.WEEK, 1); // 2006-03-13 06:05:06.007 
    1027   assert(datePart(ts, DatePart.YEARDAY) == 72); 
    1028   assert(datePart(ts, DatePart.WEEKDAY) == 0); 
    1029   assert(datePart(ts, DatePart.WEEK) == 11); 
    1030   writefln(timeStampToString(ts)); 
    1031   ts = incTimeStamp(ts, DatePart.MONTH, -14); // 2005-01-13 06:05:06.007 
    1032   writefln(timeStampToString(ts)); 
    1033   assert(datePart(ts, DatePart.DAY) == 13); 
    1034   assert(datePart(ts, DatePart.MONTH) == 1); 
    1035   assert(datePart(ts, DatePart.YEAR) == 2005); 
     1026  ts = increment(ts, toDuration(1, 2, 3, 4, 5, 6, 7)); // 2006-03-04 04:05:06.007 
     1027  assert(extract(ts, DatePart.SECOND) == 6); 
     1028  ts = increment(ts, DatePart.SECOND, -200); // 2006-03-04 04:01:46.007  
     1029  assert(extract(ts, DatePart.MINUTE) == 1); 
     1030  ts = increment(ts, DatePart.HOUR, 50); // 2006-03-06 06:05:06.007 
     1031  assert(extract(ts, DatePart.HOUR) == 6); 
     1032  ts = increment(ts, DatePart.WEEK, 1); // 2006-03-13 06:05:06.007 
     1033  assert(extract(ts, DatePart.YEARDAY) == 72); 
     1034  assert(extract(ts, DatePart.WEEKDAY) == 0); 
     1035  assert(extract(ts, DatePart.WEEK) == 11); 
     1036  writefln(toString(ts)); 
     1037  ts = increment(ts, DatePart.MONTH, -14); // 2005-01-13 06:05:06.007 
     1038  writefln(toString(ts)); 
     1039  assert(extract(ts, DatePart.DAY) == 13); 
     1040  assert(extract(ts, DatePart.MONTH) == 1); 
     1041  assert(extract(ts, DatePart.YEAR) == 2005); 
    10361042} 
    10371043 
     
    10461052 * Returns: A d_timestamp date/time. 
    10471053 */ 
    1048 public d_timestamp truncTimeStamp(d_timestamp timestamp, DatePart datePart) { 
     1054public d_timestamp truncate(d_timestamp timestamp, DatePart datePart) { 
    10491055  if (datePart == DatePart.DAY) { 
    10501056    return cast(d_timestamp)(cast(int)timestamp); 
    10511057  } else { 
    10521058    if (datePart < DatePart.HOUR) { 
    1053       return toTimeStamp(truncDate(dateOfTimeStamp(timestamp), datePart), 0); 
     1059      return toTimeStamp(truncate(dateOfTimeStamp(timestamp), datePart), 0); 
    10541060    } else { 
    10551061      return toTimeStamp(dateOfTimeStamp(timestamp),  
    1056           truncTime(timeOfTimeStamp(timestamp), datePart)); 
     1062          truncate(timeOfTimeStamp(timestamp), datePart)); 
    10571063    } 
    10581064  } 
     
    10601066unittest { 
    10611067  d_timestamp ts = toTimeStamp("2006-03-19 12:26:42"); 
    1062   assert(truncTimeStamp(ts, DatePart.MINUTE) == toTimeStamp("2006-03-19 12:26:00")); 
    1063   assert(truncTimeStamp(ts, DatePart.HOUR) == toTimeStamp("2006-03-19 12:00:00")); 
    1064   assert(truncTimeStamp(ts, DatePart.DAY) == toTimeStamp("2006-03-19 00:00:00")); 
    1065   assert(truncTimeStamp(ts, DatePart.WEEK) == toTimeStamp("2006-03-13 00:00:00")); 
    1066   assert(truncTimeStamp(ts, DatePart.MONTH) == toTimeStamp("2006-03-01 00:00:00")); 
    1067   assert(truncTimeStamp(ts, DatePart.QUARTER) == toTimeStamp("2006-01-01 00:00:00")); 
    1068   assert(truncTimeStamp(ts, DatePart.YEAR) == toTimeStamp("2006-01-01 00:00:00")); 
    1069   assert(truncTimeStamp(ts, DatePart.DECADE) == toTimeStamp("2000-01-01 00:00:00")); 
    1070   assert(truncTimeStamp(ts, DatePart.MILLENIA) == toTimeStamp("2000-01-01 00:00:00")); 
     1068  assert(truncate(ts, DatePart.MINUTE) == toTimeStamp("2006-03-19 12:26:00")); 
     1069  assert(truncate(ts, DatePart.HOUR) == toTimeStamp("2006-03-19 12:00:00")); 
     1070  assert(truncate(ts, DatePart.DAY) == toTimeStamp("2006-03-19 00:00:00")); 
     1071  assert(truncate(ts, DatePart.WEEK) == toTimeStamp("2006-03-13 00:00:00")); 
     1072  assert(truncate(ts, DatePart.MONTH) == toTimeStamp("2006-03-01 00:00:00")); 
     1073  assert(truncate(ts, DatePart.QUARTER) == toTimeStamp("2006-01-01 00:00:00")); 
     1074  assert(truncate(ts, DatePart.YEAR) == toTimeStamp("2006-01-01 00:00:00")); 
     1075  assert(truncate(ts, DatePart.DECADE) == toTimeStamp("2000-01-01 00:00:00")); 
     1076  assert(truncate(ts, DatePart.MILLENIA) == toTimeStamp("2000-01-01 00:00:00")); 
    10711077} 
    10721078 
     
    10821088 * Returns: A d_time time. 
    10831089 */ 
    1084 public d_timestamp incTimeStamp(d_timestamp timestamp, DatePart datePart, int count) { 
     1090public d_timestamp increment(d_timestamp timestamp, DatePart datePart, int count) { 
    10851091  if (datePart < DatePart.HOUR) { 
    1086     return toTimeStamp(incDate(dateOfTimeStamp(timestamp), datePart, count),  
     1092    return toTimeStamp(increment(dateOfTimeStamp(timestamp), datePart, count),  
    10871093        timeOfTimeStamp(timestamp)); 
    10881094  } else { 
     
    11011107        break; 
    11021108      default: 
    1103         throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     1109        throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    11041110            " is an invalid date part"); 
    11051111    } 
     
    11181124 * Returns: A d_timestamp date/time. 
    11191125 */ 
    1120 public d_timestamp incTimeStamp(d_timestamp timestamp, d_duration duration) { 
    1121   return incTimeStamp(timestamp, DatePart.MONTH, duration.months) +  
     1126public d_timestamp increment(d_timestamp timestamp, d_duration duration) { 
     1127  return increment(timestamp, DatePart.MONTH, duration.months) +  
    11221128      cast(d_timestamp)duration.daysAndTime; 
    11231129} 
     
    11841190 * Returns: The d_duration duration as a string. 
    11851191 */ 
    1186 public char[] durationToString(d_duration duration) { 
     1192public char[] toString(d_duration duration) { 
    11871193  assert(0); 
    11881194} 
     
    13521358 * Returns: The datepart of an duration. 
    13531359 */ 
    1354 public int datePart(d_duration duration, DatePart datePart) { 
     1360public int extract(d_duration duration, DatePart datePart) { 
    13551361  if (datePart < DatePart.HOUR) { 
    13561362    switch (datePart) { 
     
    13701376        return cast(int)duration.daysAndTime; 
    13711377      default: 
    1372         throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     1378        throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    13731379            " is an invalid date part"); 
    13741380    } 
     
    13851391        return cast(int)((timePart * MSEC_PER_DAY) % 1000); 
    13861392      default: 
    1387         throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     1393        throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    13881394            " is an invalid date part"); 
    13891395    } 
     
    14051411 * Returns: A d_timestamp date/time. 
    14061412 */ 
    1407 public d_duration truncDuration(d_duration duration, DatePart datePart) { 
     1413public d_duration truncate(d_duration duration, DatePart datePart) { 
    14081414  if (datePart < DatePart.WEEK) { 
    14091415    duration.daysAndTime = 0.0; 
     
    14451451      break; 
    14461452    default: 
    1447       throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     1453      throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    14481454          " is an invalid date part"); 
    14491455  } 
     
    14621468 * Returns: An d_duration duration. 
    14631469 */ 
    1464 public d_duration incDuration(d_duration duration, DatePart datePart,  
     1470public d_duration increment(d_duration duration, DatePart datePart,  
    14651471    int count) { 
    14661472  switch (datePart) { 
     
    14991505      break; 
    15001506    default: 
    1501       throw new InvalidDatePartException(toString(cast(int)datePart) ~  
     1507      throw new InvalidDatePartException(std.string.toString(cast(int)datePart) ~  
    15021508          " is an invalid date part"); 
    15031509  } 
     
    15151521 * Returns: An d_duration date/time. 
    15161522 */ 
    1517 public d_duration incDuration(d_duration duration, d_duration addduration) { 
     1523public d_duration increment(d_duration duration, d_duration addduration) { 
    15181524  duration.daysAndTime += addduration.daysAndTime; 
    15191525  duration.months += addduration.months; 
     
    16711677  writefln("%d-%d-%d", year, month, day); 
    16721678  writefln(weekDayOfDate(date)); 
    1673   writefln(dateToString(date)); 
     1679  writefln(toString(date)); 
    16741680  writefln(toDate(2001, 1, 1)); 
    16751681   
  • branches/dateparse.d

    r49 r50  
    620620                                tmask = maskDate(); 
    621621                                dtype = FieldType.DATE; 
    622                 splitDate(incDate(date.date(), DatePart.DAY, -1), datetime.year,  
     622                splitDate(increment(date.date(), DatePart.DAY, -1), datetime.year,  
    623623                    datetime.month, datetime.day); 
    624624                                break; 
     
    633633                                tmask = maskDate(); 
    634634                                dtype = FieldType.DATE; 
    635                 splitDate(incDate(date.date(), DatePart.DAY, 1), datetime.year,  
     635                splitDate(increment(date.date(), DatePart.DAY, 1), datetime.year,  
    636636                    datetime.month, datetime.day); 
    637637                                break;