Squeak Class Documentation category index | class index  
 
Date
  category: Kernel-Magnitudes
  superclass: Magnitude
  subclasses: Month Week

Refactored to use Julian Day Numbers internally.

Julian Day Numbers are the number of days which have elapsed since 24 November -4713 Gregorian.

The algorithm was published in the Communications of the ACM, volume 11, Number 10, October 1968.

See also:
http://www.magnet.ch/serendipity/hermetic/cal_stud/jdn.htm
http://www.cs.ubc.ca/spider/flinn/docs/scham/primitives/time.html

instance methods
  accessing
  day
julianDayNumber
julianDayNumber:
leap
monthIndex
monthName
weekday
weekdayIndex
year

  arithmetic
  addDays:
subtractDate:
subtractDays:

  comparing
  <
=
hash

  converting
  asDate
asGregorian
asJulianDayNumber
asSeconds
month
week

  inquiries
  dayOfMonth
dayOfYear
daysInMonth
daysInYear
daysLeftInYear
firstDayOfMonth
previous:

  obsolete
  day:year:
firstDayOfMonthIndex:
mmddyy

  printing
  mmddyyyy
printFormat:
printOn:
printOn:format:
storeOn:

  testing
 

class methods
  class initialization
  initialize

  general inquiries
  dateAndTimeNow
dayOfWeek:
daysInMonth:forYear:
daysInYear:
firstWeekdayOfMonth:year:
indexOfMonth:
leapYear:
nameOfDay:
nameOfMonth:

  instance creation
  fromDays:
fromJulianDayNumber:
fromSeconds:
fromString:
new
newDay:month:year:
newDay:year:
readFrom:
today

  obsolete
  absoluteDaysToYear:
yearAndDaysFromDays:into:

instance methods
  accessing top  
 

day

Answer the day of the year represented by the receiver.


 

julianDayNumber

Answer the number of days (or part of a day) elapsed since noon GMT on January 1st, 4713 B.C.


 

julianDayNumber:

Set the number of days (or part of a day) elapsed since noon GMT on January 1st, 4713 B.C.


 

leap

Answer whether the receiver's year is a leap year.


 

monthIndex

Answer the index of the month in which the receiver falls.


 

monthName

Answer the name of the month in which the receiver falls.


 

weekday

Answer the name of the day of the week on which the receiver falls.


 

weekdayIndex

Monday=1, ... , Sunday=7


 

year

Answer the year in which the receiver falls.


  arithmetic top  
 

addDays:

Answer a Date that is dayCount days after the receiver.


 

subtractDate:

Answer the number of days between the receiver and aDate.


 

subtractDays:

Answer a Date that is dayCount days before the receiver.


  comparing top  
 

<

Answer whether aDate precedes the date of the receiver.


 

=

Answer whether aDate is the same day as the receiver.


 

hash

Hash is reimplemented because = is implemented.


  converting top  
 

asDate


 

asGregorian

Return an array of integers #(dd mm yyyy)


 

asJulianDayNumber


 

asSeconds

Answer the seconds between a time on 1 January 1901 and the same
time in the receiver's day.


 

month


 

week


  inquiries top  
 

dayOfMonth

Answer which day of the month is represented by the receiver.


 

dayOfYear


 

daysInMonth

Answer the number of days in the month represented by the receiver.


 

daysInYear

Answer the number of days in the year represented by the receiver.


 

daysLeftInYear

Answer the number of days in the year after the date of the receiver.


 

firstDayOfMonth

Answer the index of the day of the year that is the first day of the receiver's month.


 

previous:

Answer the previous date whose weekday name is dayName.


  obsolete top  
 

day:year:


 

firstDayOfMonthIndex:

Answer the day of the year (an Integer) that is the first day of my month


 

mmddyy

Please use mmddyyyy instead, so dates in 2000 will be unambiguous


  printing top  
 

mmddyyyy

Answer the receiver rendered in standard fmt mm/dd/yyyy. Good for avoiding year 2000 bugs. Note that the name here is slightly misleading -- the month and day numbers don't show leading zeros, so that for example feb 1 1996 is 2/1/96


 

printFormat:

Answer a String describing the receiver using the argument formatArray.


 

printOn:

Append to the argument, aStream, a sequence of characters that
identifies the receiver.


 

printOn:format:

Print a description of the receiver on aStream using the format denoted the argument, formatArray:
#(item item item sep monthfmt yearfmt twoDigits)
items: 1=day 2=month 3=year will appear in the order given,
separated by sep which is eaither an ascii code or character.
monthFmt: 1=09 2=Sep 3=September
yearFmt: 1=1996 2=96
digits: (missing or)1=9 2=09.
See the examples in printOn: and mmddyy


 

storeOn:

Append to the argument aStream a sequence of characters that is an
expression whose evaluation creates an object similar to the receiver.


  testing top  

class methods
  class initialization top  
 

initialize

Initialize class variables representing the names of the months and days and
the number of seconds, days in each month, and first day of each month.


  general inquiries top  
 

dateAndTimeNow

Answer an Array whose first element is Date today and second element
is Time now.


 

dayOfWeek:

Answer the index in a week, 1-7, of the day named dayName. Create an
error notification if no such day exists.


 

daysInMonth:forYear:

Answer the number of days in the month named monthName in the year yearInteger.


 

daysInYear:

Answer the number of days in the year, yearInteger.


 

firstWeekdayOfMonth:year:

Answer the weekday index (Sunday=1, etc) of the first day in the month named mn in the year yr.


 

indexOfMonth:

Answer the index, 1-12, of the month monthName. Create an error
notification if no such month exists.


 

leapYear:

Answer 1 if the year yearInteger is a leap year; answer 0 if it is not.


 

nameOfDay:

Answer a symbol representing the name of the day indexed by dayIndex, 1-7.


 

nameOfMonth:

Answer a String representing the name of the month indexed by monthIndex, 1-12.


  instance creation top  
 

fromDays:

Answer an instance of me which is dayCount days after January 1, 1901. Works for negative days before 1901. Works over a huge range, both BC and AD.


 

fromJulianDayNumber:


 

fromSeconds:

Answer an instance of me which is 'seconds' seconds after January 1, 1901.


 

fromString:

Answer an instance of created from a string with format DD.MM.YYYY.


 

new

Return a constant, or date today?


 

newDay:month:year:

Arguments day, month and year are all integers, except month may be a string.
For compatibility, two digit dates in the range 00..49 are from 2000, 50..99 from 1900.
Please use ALWAYS four digits year numbers.


 

newDay:year:

Answer an instance of me which is dayCount days after the beginning of the year referenceYear.


 

readFrom:

Read a Date from the stream in any of the forms:
<day> <monthName> <year> (5 April 1982; 5-APR-82)
<monthName> <day> <year> (April 5, 1982)
<monthNumber> <day> <year> (4/5/82)


 

today

Answer an instance of me representing the day and year right now.


  obsolete top  
 

absoluteDaysToYear:

Computes the number of days from (or until) January 1 of the year 1 A.D. upto (or since) January 1 of a given year. [Alan Lovejoy]


 

yearAndDaysFromDays:into:

Compute the Gregorian year, and the day of the year, from the number of days since (or until) January 1 of the year 1 A.D. Return the values in a block. [Alan Lovejoy]