2008-08-29 16:17:15 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								! Copyright (C) 2008 Doug Coleman.  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								! See http://factorcode.org/license.txt for BSD license.  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								USING:  arrays  kernel  math  strings  help.markup  help.syntax  
						 
					
						
							
								
									
										
										
										
											2008-09-01 12:50:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								math.order ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-29 16:17:15 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								IN:  calendar  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  duration  
						 
					
						
							
								
									
										
										
										
											2011-01-05 01:55:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "A duration is a period of time years, months, days, hours, minutes, and seconds. All duration slots can store "  { $link real  } " numbers. Compare two durations with the "  { $link <=> } " word."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-29 16:17:15 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  timestamp  
						 
					
						
							
								
									
										
										
										
											2011-01-05 01:55:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "A timestamp is a date and a time with a timezone offset. Timestamp slots must store integers except for "  { $snippet "seconds"  } ", which stores reals, and "  { $snippet "gmt-offset"  } ", which stores a "  { $link duration } ". Compare two durations with the "  { $link <=> } " word."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-29 16:17:15 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ timestamp duration } related-words
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  gmt-offset-duration  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "duration"  duration } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns a "  { $link duration } " object with the GMT offset returned by "  { $link gmt-offset } "."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  <date>  
						 
					
						
							
								
									
										
										
										
											2008-08-29 16:19:41 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "year"  integer  } { "month"  integer  } { "day"  integer  } { "timestamp"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-29 16:17:15 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $description "Returns a timestamp object representing the start of the specified day in your current timezone."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
									
										
										
										
											2009-08-11 10:58:47 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { $example "USING: accessors calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "2010 12 25 <date> instant >>gmt-offset ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-20 20:08:59 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "T{ timestamp { year 2010 } { month 12 } { day 25 } }" 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-29 16:17:15 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 13:59:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  average-month  
						 
					
						
							
								
									
										
										
										
											2010-03-31 18:37:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "value"  ratio  } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 13:59:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "The length of an average month averaged over 400 years. Used internally for adding an arbitrary real number of months to a timestamp."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  months-per-year  
						 
					
						
							
								
									
										
										
										
											2010-03-31 18:37:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "value"  integer  } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 13:59:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns the number of months in a year."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  days-per-year  
						 
					
						
							
								
									
										
										
										
											2010-03-31 18:37:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "value"  ratio  } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 13:59:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns the number of days in a year averaged over 400 years. Used internally for adding an arbitrary real number of days to a timestamp."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  hours-per-year  
						 
					
						
							
								
									
										
										
										
											2010-03-31 18:37:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "value"  ratio  } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 13:59:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns the number of hours in a year averaged over 400 years. Used internally for adding an arbitrary real number of hours to a timestamp."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  minutes-per-year  
						 
					
						
							
								
									
										
										
										
											2010-03-31 18:37:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "value"  ratio  } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 13:59:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns the number of minutes in a year averaged over 400 years. Used internally for adding an arbitrary real number of minutes to a timestamp."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  seconds-per-year  
						 
					
						
							
								
									
										
										
										
											2010-03-31 18:37:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "value"  integer  } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 13:59:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns the number of seconds in a year averaged over 400 years. Used internally for adding an arbitrary real number of seconds to a timestamp."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  julian-day-number  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "year"  integer  } { "month"  integer  } { "day"  integer  } { "n"  integer  } }
							 
						 
					
						
							
								
									
										
										
										
											2011-01-05 01:55:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Calculates the Julian day number from a year, month, and day. The difference between two Julian day numbers is the number of days that have elapsed between the two corresponding dates."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 13:59:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $warning "Not valid before year -4800 BCE."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  julian-day-number>date  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "n"  integer  } { "year"  integer  } { "month"  integer  } { "day"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Converts from a Julian day number back to a year, month, and day."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ julian-day-number julian-day-number>date } related-words
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  >date<  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "year"  integer  } { "month"  integer  } { "day"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Explodes a "  { $snippet "timestamp"  } " into its year, month, and day components."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples { $example "USING: arrays calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                       "2010 8 24 <date> >date< 3array ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                       "{ 2010 8 24 }" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                       }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  >time<  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "hour"  integer  } { "minute"  integer  } { "second"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Explodes a "  { $snippet "timestamp"  } " into its hour, minute, and second components."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples { $example "USING: arrays calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                       "now noon >time< 3array ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                       "{ 12 0 0 }" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                       }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ >date< >time< } related-words
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  instant  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "duration"  duration } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Pushes a "  { $snippet "duration"  } " of zero seconds."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  years  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of years."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  months  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of months."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  days  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of days."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  weeks  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of weeks."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  hours  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of hours."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  minutes  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of minutes."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  seconds  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of seconds."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  milliseconds  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of milliseconds."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-05 16:21:23 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  microseconds  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of microseconds."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  nanoseconds  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "duration"  duration } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Creates a duration object with the specified number of nanoseconds."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ years months days hours minutes seconds milliseconds microseconds nanoseconds } related-words
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  leap-year?  
						 
					
						
							
								
									
										
										
										
											2014-05-23 23:20:15 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "obj"  object  } { "?"  boolean  } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns "  { $link t  } " if the object represents a leap year."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "2008 leap-year? ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "t" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "2010 1 1 <date> leap-year? ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "f" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  time+  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "time1"  "timestamp or duration"  } { "time2"  "timestamp or duration"  } { "time3"  "timestamp or duration"  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Adds two durations to produce a duration or adds a timestamp and a duration to produce a timestamp. The calculation takes timezones into account."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar math.order prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "10 months 2 months time+ 1 years <=> ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "+eq+" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:58:12 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { $example "USING: accessors calendar math.order prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "2010 1 1 <date> 3 days time+ day>> ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 16:54:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "4" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  duration>years  
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "x"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the length of a duration in years."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "6 months duration>years ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "1/2" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  duration>months  
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "x"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the length of a duration in months."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "30 days duration>months ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "16000/16233" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  duration>days  
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "x"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the length of a duration in days."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "6 hours duration>days ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "1/4" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  duration>hours  
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "x"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the length of a duration in hours."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "3/4 days duration>hours ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "18" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  duration>minutes  
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "x"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the length of a duration in minutes."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "6 hours duration>minutes ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "360" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  duration>seconds  
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "x"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the length of a duration in seconds."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "6 minutes duration>seconds ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "360" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 22:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  duration>milliseconds  
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "x"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the length of a duration in milliseconds."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "6 seconds duration>milliseconds ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 21:19:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "6000" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 22:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-05 16:21:23 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  duration>microseconds  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "x"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the length of a duration in microseconds."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "6 seconds duration>microseconds ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "6000000" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  duration>nanoseconds  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "x"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the length of a duration in nanoseconds."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "6 seconds duration>nanoseconds ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "6000000000" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ duration>years duration>months duration>days duration>hours duration>minutes duration>seconds duration>milliseconds duration>microseconds duration>nanoseconds } related-words
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 22:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  time-  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "time1"  "timestamp or duration"  } { "time2"  "timestamp or duration"  } { "time3"  "timestamp or duration"  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Subtracts two durations to produce a duration or subtracts a duration from a timestamp to produce a timestamp. The calculation takes timezones into account."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar math.order prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "10 months 2 months time- 8 months <=> ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "+eq+" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: accessors calendar math.order prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "2010 1 1 <date> 3 days time- day>> ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "29" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  convert-timezone  
						 
					
						
							
								
									
										
										
										
											2010-02-18 18:31:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "duration"  duration } { "timestamp'"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 22:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Converts the "  { $snippet "timestamp"  } "'s "  { $snippet "gmt-offset"  } " to the GMT offset represented by the "  { $snippet "duration"  } "."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: accessors calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "gmt noon instant -5 >>hour convert-timezone gmt-offset>> hour>> ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "-5" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  >local-time  
						 
					
						
							
								
									
										
										
										
											2010-02-18 18:31:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "timestamp'"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 22:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Converts the "  { $snippet "timestamp"  } " to the timezone of your computer."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: accessors calendar kernel prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2012-07-21 13:22:44 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "now gmt >local-time [ gmt-offset>> ] same? ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-31 22:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "t" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 12:43:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  >gmt  
						 
					
						
							
								
									
										
										
										
											2010-02-18 18:31:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "timestamp'"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 12:43:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Converts the "  { $snippet "timestamp"  } " to the GMT timezone."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: accessors calendar kernel prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "now >gmt gmt-offset>> hour>> ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "0" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  time*  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "obj1"  object  } { "obj2"  object  } { "obj3"  object  } }
							 
						 
					
						
							
								
									
										
										
										
											2011-01-05 01:55:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Multiplies each time slot of a timestamp or duration by a number and make a new duration from the result. Used in the implementation of "  { $link before } "."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 12:43:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ time+ time- time* } related-words
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  before  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "-duration"  duration } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Negates a duration."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: accessors calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "3 hours before now noon time+ hour>> ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "9" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  unix-1970  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2009-11-16 17:44:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns the beginning of UNIX time, or midnight, January 1, 1970."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-11-19 02:50:05 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  micros>timestamp  
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "x"  number  } { "timestamp"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2008-11-19 02:50:05 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Converts a number of microseconds into a timestamp value in GMT time."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: accessors calendar prettyprint ;" 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-19 02:50:05 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "1000 micros>timestamp year>> ." 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								               "1970" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  gmt  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2009-11-16 17:44:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns the time right now, but in the GMT timezone."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ gmt now } related-words
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  now  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2009-11-16 17:44:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns the time right now in your computer's timezone."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $unchecked-example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        "now ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         "T{ timestamp f 2008 9 1 16 38 24+801/1000 T{ duration f 0 0 0 -5 0 0 } }" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  hence  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Computes a time in the future that is the "  { $snippet "duration"  } " added to the result of "  { $link now } "."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $unchecked-example
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       "10 hours hence ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       "T{ timestamp f 2008 9 2 2 47 45+943/1000 T{ duration f 0 0 0 -5 0 0 } }" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  ago  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "duration"  duration } { "timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Computes a time in the past that is the "  { $snippet "duration"  } " subtracted from the result of "  { $link now } "."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $unchecked-example
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       "3 weeks ago ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       "T{ timestamp f 2008 8 11 16 49 52+99/500 T{ duration f 0 0 0 -5 0 0 } }" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  zeller-congruence  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "year"  integer  } { "month"  integer  } { "day"  integer  } { "n"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "An implementation of an algorithm that computes the day of the week given a date. Days are indexed starting from Sunday, which is index 0."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $notes "User code should use the "  { $link day-of-week } " word, which takes a "  { $snippet "timestamp"  } " instead of integers."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  days-in-year  
						 
					
						
							
								
									
										
										
										
											2011-01-05 01:55:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "obj"  "a timestamp or an integer"  } { "n"  integer  } }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Calculates the number of days in a given year."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "2004 days-in-year ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "366" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  days-in-month  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "n"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the number of days in a given month."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "2008 8 24 <date> days-in-month ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "31" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  day-of-week  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "n"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the index of the day of the week. Sunday will result in an index of 0."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "now sunday day-of-week ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "0" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  day-of-year  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "n"  integer  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates the day of the year, resulting in a number from 1 to 366 (leap years)."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { $example "USING: calendar prettyprint ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "2008 1 4 <date> day-of-year ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               "4" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  sunday  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns the Sunday from the current week, which starts on a Sunday."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  monday  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns the Monday from the current week, which starts on a Sunday."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  tuesday  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns the Tuesday from the current week, which starts on a Sunday."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  wednesday  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns the Wednesday from the current week, which starts on a Sunday."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  thursday  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns the Thursday from the current week, which starts on a Sunday."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  friday  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns the Friday from the current week, which starts on a Sunday."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  saturday  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns the Saturday from the current week, which starts on a Sunday."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ sunday monday tuesday wednesday thursday friday saturday } related-words
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  midnight  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2012-02-02 22:47:05 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns a new timestamp that represents the day at midnight, or the beginning of the day."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  noon  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2012-02-02 22:47:05 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns a new timestamp that represents the day at noon, or the middle of the day."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  today  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns a timestamp that represents today at midnight."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  beginning-of-month  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2009-11-16 17:44:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns a new timestamp with the day set to one."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  beginning-of-week  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
									
										
										
										
											2009-11-16 17:44:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Returns a new timestamp where the day of the week is Sunday."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  beginning-of-year  
						 
					
						
							
								
									
										
										
										
											2009-11-16 17:44:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "object"  object  } { "new-timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Returns a new timestamp with the month and day set to one, or January 1 of the input timestamp, given a year or a timestamp."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 19:06:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  time-since-midnight  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "timestamp"  timestamp } { "duration"  duration } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Calculates a "  { $snippet "duration"  } " that represents the elapsed time since midnight of the input "  { $snippet "timestamp"  } "."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-06 22:04:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  since-1970  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     { "duration"  duration }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     { "timestamp"  timestamp } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Adds the duration to the beginning of Unix time and returns the result as a timestamp."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								ARTICLE: "calendar"  "Calendar" 
							 
						 
					
						
							
								
									
										
										
										
											2010-09-18 20:41:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"The "  { $vocab-link "calendar"  } " vocabulary defines two data types and a set of operations on them:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    timestamp
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Durations represent spans of time:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections "using-durations"  }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Arithmetic on timestamps and durations:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections "timestamp-arithmetic"  }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Getting the current timestamp:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    now
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    gmt
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2010-09-18 20:41:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Time zones:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >local-time
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >gmt
							 
						 
					
						
							
								
									
										
										
										
											2010-09-18 20:41:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    convert-timezone
							 
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Timestamps relative to each other:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections "relative-timestamps"  }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Operations on units of time:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "years" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "months" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "days" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2010-09-18 20:41:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Both "  { $link timestamp } "s and "  { $link duration } "s implement the "  { $link "math.order"  } "."  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$nl
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Meta-data about the calendar:"  
						 
					
						
							
								
									
										
										
										
											2010-09-18 20:41:56 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections "calendar-facts"  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								ARTICLE: "timestamp-arithmetic"  "Timestamp arithmetic" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Adding timestamps and durations, or durations and durations:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections time+ }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Subtracting:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections time- }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Element-wise multiplication:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections time* } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								ARTICLE: "using-durations"  "Using durations" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Creating a duration object:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    years
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    months
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    weeks
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    days
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hours
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    minutes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    seconds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    milliseconds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    microseconds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    nanoseconds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    instant
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Converting a duration to a number:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration>years
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration>months
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration>days
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration>hours
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration>minutes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration>seconds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration>milliseconds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration>microseconds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    duration>nanoseconds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ARTICLE: "relative-timestamps"  "Relative timestamps" 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"In the future:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections hence }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"In the past:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections ago }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Invert a duration:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections before }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Days of the week relative to "  { $link now } ":"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sunday
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    monday
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    tuesday
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    wednesday
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    thursday
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    friday
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    saturday
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"New timestamps relative to calendar events:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    beginning-of-year
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    beginning-of-month
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    beginning-of-week
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    midnight
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    noon
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ARTICLE: "calendar-facts"  "Calendar facts" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Calendar facts:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    average-month
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    months-per-year
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    days-per-year
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hours-per-year
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    minutes-per-year
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    seconds-per-year
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    days-in-month
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    day-of-year
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    day-of-week
							 
						 
					
						
							
								
									
										
										
										
											2017-01-03 09:48:08 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Calculating a Julian day number:"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsections julian-day-number }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Calculate a timestamp:"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $subsections julian-day-number>date } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ARTICLE: "years"  "Year operations" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Leap year predicate:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections leap-year? }
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Find the number of days in a year:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections days-in-year } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 23:16:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-01 21:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								ABOUT: "calendar"