AbstractTime.st
changeset 25315 8227a9ce831d
parent 24423 27a335bed151
equal deleted inserted replaced
25314:a91d744724d0 25315:8227a9ce831d
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1995 by Claus Gittinger
     4  COPYRIGHT (c) 1995 by Claus Gittinger
     3               All Rights Reserved
     5               All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
  1657 
  1659 
  1658         %t      seconds within hour  (unpadded)
  1660         %t      seconds within hour  (unpadded)
  1659         %T      seconds from midNight  (unpadded)
  1661         %T      seconds from midNight  (unpadded)
  1660 
  1662 
  1661         %(TZD)  timeZone delta of the receiver from UTC in the format +/-hh:mm
  1663         %(TZD)  timeZone delta of the receiver from UTC in the format +/-hh:mm
       
  1664         %(TZD822) timeZone delta of the receiver from UTC in the(RFC822-)format +/-hhmm
  1662 
  1665 
  1663         %(milli1) milliseconds, truncated to 1/10th of a second 0..9
  1666         %(milli1) milliseconds, truncated to 1/10th of a second 0..9
  1664         %(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2
  1667         %(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2
  1665         %(milli3) milliseconds, same as %i for convenience
  1668         %(milli3) milliseconds, same as %i for convenience
  1666 
  1669 
  1725           YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
  1728           YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
  1726                 Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'
  1729                 Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)'
  1727 
  1730 
  1728     "
  1731     "
  1729 
  1732 
  1730     |usHours ampm s zone tzDelta|
  1733     |usHours ampm s zone tzDelta s0 s1 s2 s822|
  1731 
  1734 
  1732     self addBasicPrintBindingsTo:aDictionary language:languageOrNil.
  1735     self addBasicPrintBindingsTo:aDictionary language:languageOrNil.
  1733     zone := self timeZoneName.
  1736     zone := self timeZoneName.
  1734     tzDelta := self timeZoneDeltaInMinutes.
  1737     tzDelta := self timeZoneDeltaInMinutes.
  1735 
  1738 
  1736     ampm := self meridianAbbreviation.
  1739     ampm := self meridianAbbreviation.
  1737     usHours := self hour12 printString.
  1740     usHours := self hour12 printString.
  1738     aDictionary at:$U put:usHours.
  1741     aDictionary at:$U put:usHours.
  1739     aDictionary at:$u put:(usHours leftPaddedTo:2 with:$0).
  1742     aDictionary at:$u put:(usHours leftPaddedTo:2 with:$0).
  1740 
  1743 
  1741 
       
  1742     aDictionary at:$a put:ampm.
  1744     aDictionary at:$a put:ampm.
  1743     aDictionary at:$A put:ampm asUppercase.
  1745     aDictionary at:$A put:ampm asUppercase.
  1744     aDictionary at:$z put:zone.
  1746     aDictionary at:$z put:zone.
  1745     aDictionary at:$Z put:zone asUppercase.
  1747     aDictionary at:$Z put:zone asUppercase.
  1746 
  1748 
  1747     tzDelta == 0 ifTrue:[
  1749     tzDelta == 0 ifTrue:[
  1748         s := 'Z'.
  1750         s := 'Z'.
       
  1751         s822 := '+0000'
  1749     ] ifFalse:[
  1752     ] ifFalse:[
  1750         s := tzDelta < 0 ifTrue:[ '-' ] ifFalse:[ '+' ].
  1753         s0 := tzDelta < 0 ifTrue:[ '-' ] ifFalse:[ '+' ].
  1751         tzDelta := tzDelta abs.
  1754         tzDelta := tzDelta abs.
  1752         s := s  , ((tzDelta // 60) printStringLeftPaddedTo:2 with:$0),
  1755         
  1753             ':' , ((tzDelta \\ 60) printStringLeftPaddedTo:2 with:$0).
  1756         s1 := ((tzDelta // 60) printStringLeftPaddedTo:2 with:$0).
       
  1757         s2 := ((tzDelta \\ 60) printStringLeftPaddedTo:2 with:$0).
       
  1758         s := s0, s1, ':', s2.
       
  1759         s822 := s0, s1, s2.
  1754     ].
  1760     ].
       
  1761     aDictionary at:#TZD822 put:s822.
  1755     aDictionary at:#TZD put:s
  1762     aDictionary at:#TZD put:s
  1756 
  1763 
  1757 
  1764 
  1758     "
  1765     "
  1759       |dict|
  1766       |dict|
  1760       dict := Dictionary new.
  1767       dict := Dictionary new.
  1761       Timestamp now addPrintBindingsTo:dict language:#en.
  1768       Timestamp now addPrintBindingsTo:dict language:#en.
  1762       dict inspect
  1769       dict inspect
  1763     "
  1770     "
       
  1771 
       
  1772     "Modified (format): / 03-03-2020 / 17:49:57 / Stefan Vogel"
  1764 !
  1773 !
  1765 
  1774 
  1766 printIso8601CompressedOn:aStream
  1775 printIso8601CompressedOn:aStream
  1767     self subclassResponsibility
  1776     self subclassResponsibility
  1768 
  1777