Date.st
changeset 7327 ab17eb5f11a6
parent 7299 ae1b90fe7c4f
child 7512 07c56e8934f4
equal deleted inserted replaced
7326:ce7d54205527 7327:ab17eb5f11a6
  1703     "
  1703     "
  1704      Date today asTimestamp
  1704      Date today asTimestamp
  1705     "
  1705     "
  1706 ! !
  1706 ! !
  1707 
  1707 
  1708 
       
  1709 !Date methodsFor:'printing & storing'!
  1708 !Date methodsFor:'printing & storing'!
  1710 
  1709 
  1711 addPrintBindingsTo:aDictionary
  1710 addPrintBindingsTo:aDictionary
  1712     "add bindings for printing to aDictionary."
  1711     "add bindings for printing to aDictionary."
  1713 
  1712 
  1775 
  1774 
  1776     aDictionary at:#shortMonthName put:(mn := self abbreviatedMonthName).
  1775     aDictionary at:#shortMonthName put:(mn := self abbreviatedMonthName).
  1777     aDictionary at:#ShortMonthName put:mn asUppercaseFirst.
  1776     aDictionary at:#ShortMonthName put:mn asUppercaseFirst.
  1778     aDictionary at:#SHORTMONTHNAME put:mn asUppercase.
  1777     aDictionary at:#SHORTMONTHNAME put:mn asUppercase.
  1779 
  1778 
  1780     aDictionary at:#nth put:(#('th' 'st' 'nd' 'rd' 'th' 'th' 'th' 'th' 'th' 'th') at:d \\ 10 + 1).
  1779     aDictionary at:#nth        put:(#('th' 'st' 'nd' 'rd' 'th' 'th' 'th' 'th' 'th' 'th') at:d \\ 10 + 1).
  1781                               "/ 0   1    2    3    4    5    6    7    8    9
  1780                                      "/ 0   1    2    3    4    5    6    7    8    9
       
  1781     aDictionary at:#weekDayNth put:(#('th' 'st' 'nd' 'rd' 'th' 'th' 'th') at:dw-1 \\ 10 + 1).
       
  1782                                      "/ 0   1    2    3    4    5    6      
       
  1783     aDictionary at:#weekNth    put:(#('th' 'st' 'nd' 'rd' 'th' 'th' 'th' 'th' 'th' 'th') at:w \\ 10 + 1).
       
  1784                                      "/ 0   1    2    3    4    5    6    7    8    9     
  1782 !
  1785 !
  1783 
  1786 
  1784 printOn:aStream
  1787 printOn:aStream
  1785     "append a printed representation of the receiver to aStream"
  1788     "append a printed representation of the receiver to aStream"
  1786 
  1789 
  1825         %shortMonthName - short (abbreviated) month name     
  1828         %shortMonthName - short (abbreviated) month name     
  1826         %ShortMonthName - short (abbreviated) month name, first character uppercase      
  1829         %ShortMonthName - short (abbreviated) month name, first character uppercase      
  1827         %SHORTMONTHNAME - short (abbreviated) month name, all uppercase       
  1830         %SHORTMONTHNAME - short (abbreviated) month name, all uppercase       
  1828 
  1831 
  1829         %nth           - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
  1832         %nth           - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
       
  1833         %weekDayNth    - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
       
  1834         %weekNth       - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
  1830 
  1835 
  1831      for ST80/squeak compatibility (which expects a format-array), the following is also supported:
  1836      for ST80/squeak compatibility (which expects a format-array), the following is also supported:
  1832         #(item item item sep monthfmt yearfmt twoDigits)
  1837         #(item item item sep monthfmt yearfmt twoDigits)
  1833             items:  1=day  2=month  3=year  will appear in the order given,
  1838             items:  1=day  2=month  3=year  will appear in the order given,
  1834             separated by sep which is eaither an ascii code or character.
  1839             separated by sep which is eaither an ascii code or character.
  1897         %shortMonthName - short (abbreviated) month name     
  1902         %shortMonthName - short (abbreviated) month name     
  1898         %ShortMonthName - short (abbreviated) month name, first character uppercase      
  1903         %ShortMonthName - short (abbreviated) month name, first character uppercase      
  1899         %SHORTMONTHNAME - short (abbreviated) month name, all uppercase       
  1904         %SHORTMONTHNAME - short (abbreviated) month name, all uppercase       
  1900 
  1905 
  1901         %nth           - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
  1906         %nth           - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
       
  1907         %weekDayNth    - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
       
  1908         %weekNth       - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')      
  1902     "
  1909     "
  1903 
  1910 
  1904     |dict|
  1911     |dict|
  1905 
  1912 
  1906     dict := IdentityDictionary new.
  1913     dict := IdentityDictionary new.
  1918      Date today printStringFormat:'%D-%(MonthName)-%y'                          (us trivia format)
  1925      Date today printStringFormat:'%D-%(MonthName)-%y'                          (us trivia format)
  1919      Date today printStringFormat:'%D-%(MONTHNAME)-%y'                          (us trivia format)
  1926      Date today printStringFormat:'%D-%(MONTHNAME)-%y'                          (us trivia format)
  1920      Date today printStringFormat:'%(DayName), %D%(nth) of %(MonthName), %y'   
  1927      Date today printStringFormat:'%(DayName), %D%(nth) of %(MonthName), %y'   
  1921      Date today printStringFormat:'%(ShortDayName), %D-%(ShortMonthName)-%y'   
  1928      Date today printStringFormat:'%(ShortDayName), %D-%(ShortMonthName)-%y'   
  1922      Date today printStringFormat:'%d%m%Y'                                      (millenium bug format - danger)
  1929      Date today printStringFormat:'%d%m%Y'                                      (millenium bug format - danger)
  1923      Date today printStringFormat:'Today is the %(weekDay) day of the week'     
  1930      Date today printStringFormat:'Today is day %(weekDay) of the week'              
       
  1931      Date today printStringFormat:'Today is the %(weekDay)%(weekDayNth) day of the week'     
       
  1932      Date today printStringFormat:'Today is the %(Day)%(nth) day of the month'           
  1924     "
  1933     "
  1925 !
  1934 !
  1926 
  1935 
  1927 storeOn:aStream
  1936 storeOn:aStream
  1928     "append a representation to aStream, from which the receiver
  1937     "append a representation to aStream, from which the receiver
  1982 ! !
  1991 ! !
  1983 
  1992 
  1984 !Date class methodsFor:'documentation'!
  1993 !Date class methodsFor:'documentation'!
  1985 
  1994 
  1986 version
  1995 version
  1987     ^ '$Header: /cvs/stx/stx/libbasic/Date.st,v 1.72 2003-05-19 10:54:35 cg Exp $'
  1996     ^ '$Header: /cvs/stx/stx/libbasic/Date.st,v 1.73 2003-06-03 10:36:32 cg Exp $'
  1988 ! !
  1997 ! !
  1989 
  1998 
  1990 Date initialize!
  1999 Date initialize!