- README

- Top Level Namespace
- Adler32
- ArgumentError
- Array
- Atomic
- Base64
  - Error
- Benchmark
  - BM
    - Job
    - Tms
  - IPS
    - Entry
    - Job
- BigFloat
- BigInt
- BigRational
- BitArray
- Bool
- Box
- Bytes
- Channel
  - Buffered
  - ClosedError
  - ReceiveAction
  - SelectAction
  - SendAction
  - Unbuffered
- Char
  - Reader
- Class
- Colorize
  - Object
  - ObjectExtensions
- Comparable
- Complex
- Concurrent
  - CanceledError
- CRC32
- Crypto
  - Bcrypt
    - Error
    - Password
  - Blowfish
  - Subtle
- Crystal
  - Macros
    - And
    - Arg
    - ArrayLiteral
    - Assign
    - ASTNode
    - BinaryOp
    - Block
    - BoolLiteral
    - Call
    - Case
    - Cast
    - CharLiteral
    - ClassDef
    - ClassVar
    - Def
    - Expressions
    - Generic
    - Global
    - HashLiteral
    - If
    - ImplicitObj
    - InstanceSizeOf
    - InstanceVar
    - IsA
    - Macro
    - MacroId
    - MetaVar
    - MultiAssign
    - NamedArgument
    - NamedTupleLiteral
    - NilableCast
    - NilLiteral
    - Nop
    - Not
    - NumberLiteral
    - Or
    - Out
    - Path
    - PointerOf
    - RangeLiteral
    - ReadInstanceVar
    - RegexLiteral
    - Require
    - RespondsTo
    - SizeOf
    - Splat
    - StringInterpolation
    - StringLiteral
    - SymbolLiteral
    - TupleLiteral
    - TypeDeclaration
    - TypeNode
    - UnaryExpression
    - UninitializedVar
    - Union
    - Var
    - VisibilityModifier
    - When
    - While
  - System
- CSV
  - Builder
    - Row
  - Error
  - Lexer
  - MalformedCSVError
  - Parser
  - Row
  - Token
    - Kind
- Debug
  - DWARF
    - Abbrev
      - Attribute
    - AT
    - FORM
    - Info
      - Value
    - LineNumbers
      - Register
      - Row
      - Sequence
    - LNE
    - LNS
    - Strings
    - TAG
  - ELF
    - Endianness
    - Error
    - Ident
    - Klass
    - Machine
    - OSABI
    - SectionHeader
      - Flags
      - Type
    - Type
- Deque
- Digest
  - Base
  - MD5
  - SHA1
- Dir
- DivisionByZero
- DL
- ECR
- Enum
- Enumerable
  - EmptyError
- ENV
- Errno
- Exception
- Fiber
- File
  - Stat
- FileUtils
- Flate
  - Error
  - Reader
  - Strategy
  - Writer
- Float
  - Primitive
  - Printer
    - CachedPowers
      - Power
    - DiyFP
    - Grisu3
    - IEEE
- Float32
- Float64
- GC
  - Stats
- Gzip
  - Error
  - Header
  - Reader
  - Writer
- Hash
- HTML
- HTTP
  - Client
    - BodyType
    - Response
  - CompressHandler
  - ComputedContentTypeHeader
  - Cookie
  - Cookies
  - ErrorHandler
  - FormData
    - Builder
    - Error
    - FileMetadata
    - Parser
    - Part
  - Handler
    - Proc
  - Headers
  - LogHandler
  - Multipart
    - Builder
    - Error
    - Parser
  - Params
    - Builder
  - Request
  - Server
    - Context
    - RequestProcessor
    - Response
  - StaticFileHandler
    - DirectoryListing
  - WebSocket
  - WebSocketHandler
- Indexable
- IndexError
- INI
- Int
  - Primitive
  - Signed
  - Unsigned
- Int16
- Int32
- Int64
- Int8
- InvalidByteSequenceError
- IO
  - Buffered
  - ByteFormat
    - BigEndian
    - LittleEndian
    - NetworkEndian
    - SystemEndian
  - Delimited
  - EncodingOptions
  - EOFError
  - Error
  - FileDescriptor
  - Hexdump
  - Memory
  - MultiWriter
  - Seek
  - Sized
  - Timeout
- IPSocket
- Iterable
- Iterator
  - IteratorWrapper
  - Stop
- JSON
  - Any
  - Builder
    - ArrayState
    - DocumentEndState
    - DocumentStartState
    - ObjectState
    - StartState
    - State
  - Error
  - Lexer
  - ParseException
  - Parser
  - PullParser
  - Token
  - Type
- KeyError
- Levenshtein
  - Finder
- LLVM
  - ABI
    - AArch64
    - ArgKind
    - ArgType
    - ARM
    - FunctionType
    - X86
    - X86_64
      - RegClass
  - AtomicOrdering
  - AtomicRMWBinOp
  - Attribute
  - AttributeIndex
  - BasicBlock
  - BasicBlockCollection
  - Builder
  - CallConvention
  - CodeGenFileType
  - CodeGenOptLevel
  - CodeModel
  - Context
  - DIBuilder
  - DIFlags
  - DwarfTag
  - DwarfTypeEncoding
  - Function
  - FunctionCollection
  - FunctionPassManager
    - Runner
  - GenericValue
  - GlobalCollection
  - InstructionCollection
  - IntPredicate
  - JITCompiler
  - Linkage
  - MemoryBuffer
  - Module
  - ModuleFlag
  - ModulePassManager
  - OperandBundleDef
  - ParameterCollection
  - PassManagerBuilder
  - PassRegistry
  - PhiTable
  - RealPredicate
  - RelocMode
  - Target
  - TargetData
  - TargetMachine
  - Type
    - Kind
  - Value
    - Kind
  - ValueMethods
  - VerifierFailureAction
- Logger
  - Formatter
  - Severity
- Markdown
  - HTMLRenderer
  - Parser
    - PrefixHeader
    - UnorderedList
  - Renderer
- Math
- Mutex
- NamedTuple
- Nil
- Number
  - Primitive
- OAuth
  - AccessToken
  - Consumer
  - Error
  - RequestToken
- OAuth2
  - AccessToken
    - Bearer
    - Mac
  - Client
  - Error
  - Session
- Object
- OpenSSL
  - Digest
    - Error
    - UnsupportedError
  - DigestBase
  - DigestIO
    - DigestMode
  - Error
  - HMAC
  - MD5
  - SHA1
  - SSL
    - Context
      - Client
      - Server
    - Error
    - ErrorType
    - Modes
    - Options
    - Socket
      - Client
      - Server
    - VerifyMode
    - X509VerifyFlags
- OptionParser
  - Exception
  - InvalidOption
  - MissingOption
- PartialComparable
- Pointer
  - Appender
- PrettyPrint
- Proc
- Process
  - Env
  - Status
  - Stdio
  - Tms
- Random
  - ISAAC
  - MT19937
  - PCG32
  - System
- Range
- Readline
  - CompletionProc
  - KeyBindingProc
- Reference
- Reflect
- Regex
  - MatchData
  - Options
- SecureRandom
- Set
- Signal
- Slice
- Socket
  - Address
  - Addrinfo
  - Error
  - Family
  - IPAddress
  - Protocol
  - Server
  - Type
  - UNIXAddress
- Spec
  - Expectations
  - Methods
  - ObjectExtensions
- StaticArray
- String
  - Builder
  - RawConverter
- StringPool
- StringScanner
- Struct
- Symbol
- System
- TCPServer
- TCPSocket
- Tempfile
- Termios
  - AttributeSelection
  - BaudRate
  - ControlMode
  - InputMode
  - LineControl
  - LocalMode
  - OutputMode
- Time
  - DayOfWeek
  - EpochConverter
  - EpochMillisConverter
  - Format
    - Error
  - Kind
  - MonthSpan
  - Span
- Tuple
- TypeCastError
- UDPSocket
- UInt16
- UInt32
- UInt64
- UInt8
- Unicode
  - CaseOptions
- Union
- UNIXServer
- UNIXSocket
- URI
  - Error
- Value
- WeakRef
- XML
  - Attributes
  - AttributeType
  - Builder
  - Error
  - HTMLParserOptions
  - Namespace
  - Node
  - NodeSet
  - ParserOptions
  - Reader
  - SaveOptions
  - Type
  - XPathContext
- YAML
  - Any
  - Builder
  - Error
  - EventKind
  - ParseException
  - Parser
  - PullParser
  - Type
- Zip
  - CompressionMethod
  - Error
  - File
    - Entry
  - FileInfo
  - Reader
    - Entry
  - Writer
    - Entry
- Zlib
  - Error
  - Reader
  - Writer

# struct Time

- Time
- Struct
- Value
- Object

## Overview

`Time` represents an instance in time. Here are some examples:

### Basic Usage

    time = Time.new(2016, 2, 15, 10, 20, 30)

    time.year    # => 2016
    time.month   # => 2
    time.day     # => 15
    time.hour    # => 10
    time.minute  # => 20
    time.second  # => 30
    time.monday? # => true

    # Creating a time instance with a date only
    Time.new(2016, 2, 15) # => 2016-02-15 00:00:00

    # Specifying a time
    Time.new(2016, 2, 15, 10, 20, 30) # => 2016-02-15 10:20:30 UTC

### Formatting Time

The `#to_s` method returns a `String` value in the assigned format.

    time = Time.new(2015, 10, 12)
    time.to_s("%Y-%m-%d") # => "2015-10-12"

See `Time::Format` for all the directives.

### Calculation

    Time.new(2015, 10, 10) - 5.days # => 2015-10-05 00:00:00

    # Time calculation returns a Time::Span instance
    span = Time.new(2015, 10, 10) - Time.new(2015, 9, 10)
    span.days          # => 30
    span.total_hours   # => 720
    span.total_minutes # => 43200

    # Calculation between Time::Span instances
    span_a = Time::Span.new(3, 0, 0)
    span_b = Time::Span.new(2, 0, 0)
    span = span_a - span_b
    span       # => 01:00:00
    span.class # => Time::Span
    span.hours # => 1

## Included Modules

- Comparable(self)

## Defined in:

## Constant Summary

DAYS_MONTH = `[0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]`
DAYS_MONTH_LEAP = `[0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]`
DP100 = `36524`
DP4 = `1461`
DP400 = `146097`
KindMask = `13835058055282163712_u64`
KindShift = `62_i64`
MAX_VALUE_TICKS = `3155378975999999999_i64`
MaxValue = `new(3155378975999999999_i64)`
MinValue = `new(0)`
TicksMask = `4611686018427387903_i64`
UnixEpoch = `621355968000000000_i64`

## Constructors

- .epoch(seconds : Int) : self

  Returns a new `Time` instance that corresponds to the number seconds elapsed since the unix epoch (00:00:00 UTC on 1 January 1970).

- .epoch_ms(milliseconds : Int) : self

  Returns a new `Time` instance that corresponds to the number milliseconds elapsed since the unix epoch (00:00:00 UTC on 1 January 1970).

- .new(year, month, day, hour = 0, minute = 0, second = 0, millisecond = 0, kind = Kind::Unspecified)
- .new(ticks : Int, kind = Kind::Unspecified)
- .new(time : LibC::Timespec, kind = Kind::Unspecified)
- .new(pull : JSON::PullParser)
- .new(pull : YAML::PullParser)
- .new
- .now : self
- .parse(time : String, pattern : String, kind = Time::Kind::Unspecified) : self

  Parses a Time in the given time string, using the given pattern (see `Time::Format`).

- .utc_now : self

## Class Method Summary

- .days_in_month(year, month) : Int32
- .leap_year?(year) : Bool
- .local_offset_in_minutes

  Returns the local time offset in minutes relative to GMT.

- .local_ticks
- .utc_ticks

## Instance Method Summary

- #+(other : Span)
- #+(other : MonthSpan)
- #-(other : Int)
- #-(other : Time)
- #-(other : Span)
- #-(other : MonthSpan)
- #<=>(other : self)
- #add_ticks(value)
- #at_beginning_of_day
- #at_beginning_of_hour
- #at_beginning_of_minute
- #at_beginning_of_month
- #at_beginning_of_quarter
- #at_beginning_of_semester
- #at_beginning_of_week
- #at_beginning_of_year
- #at_end_of_day
- #at_end_of_hour
- #at_end_of_minute
- #at_end_of_month
- #at_end_of_quarter
- #at_end_of_semester
- #at_end_of_week
- #at_end_of_year
- #at_midday
- #clone
- #date
- #day
- #day_of_week
- #day_of_year
- #epoch : Int64

  Returns the number of seconds since the Epoch for this time.

- #epoch_f : Float64

  Returns the number of seconds since the Epoch for this time, as a `Float64`.

- #epoch_ms : Int64

  Returns the number of milliseconds since the Epoch for this time.

- #friday?
- #hash : Int64
- #hour
- #inspect(io : IO)
- #kind

  Returns `Kind` of the instance.

- #local?

  Returns `true` if `Kind` is set to Local.

- #millisecond
- #minute
- #monday?
- #month
- #saturday?
- #second
- #sunday?
- #thursday?
- #ticks
- #time_of_day
- #to_json(json : JSON::Builder)
- #to_local
- #to_s(format : String, io : IO)

  Formats this time using the given format (see `Time::Format`) into the given io.

- #to_s(format : String) : String

  Formats this time using the given format (see `Time::Format`).

- #to_utc
- #to_yaml(yaml : YAML::Builder)
- #tuesday?
- #utc?

  Returns `true` if `Kind` is set to Utc.

- #wednesday?
- #year

### Instance methods inherited from module `Comparable(self)`

<(other : T) <, <=(other : T) <=, <=>(other : T) <=>, ==(other : T) ==, >(other : T) >, >=(other : T) >=

### Instance methods inherited from struct `Struct`

==(other : self) : Bool ==, hash : Int32 hash, inspect(io : IO) : Nil inspect, pretty_print(pp) : Nil pretty_print, to_s(io) to_s

### Instance methods inherited from struct `Value`

==(other) ==, dup dup

### Instance methods inherited from class `Object`

!=(other) !=, !~(other) !~, ==(other) ==, ===(other : JSON::Any)
===(other : YAML::Any)
===(other) ===, =~(other) =~, class class, dup dup, hash hash, inspect(io : IO)
inspect inspect, itself itself, not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, tap(&block) tap, to_json(io : IO)
to_json to_json, to_pretty_json(indent : String = " ")
to_pretty_json(io : IO, indent : String = " ") to_pretty_json, to_s
to_s(io : IO) to_s, to_yaml(io : IO)
to_yaml to_yaml, try(&block) try, unsafe_as(type : T.class) forall T unsafe_as

### Constructor methods inherited from class `Object`

from_json(string_or_io, root : String) : self
from_json(string_or_io) : self from_json, from_yaml(string_or_io) : self from_yaml

## Constructor Detail

def self.epoch(seconds : Int) : self #

Returns a new `Time` instance that corresponds to the number seconds elapsed since the unix epoch (00:00:00 UTC on 1 January 1970).

    Time.epoch(981173106) # => 2001-02-03 04:05:06 UTC

def self.epoch_ms(milliseconds : Int) : self #

Returns a new `Time` instance that corresponds to the number milliseconds elapsed since the unix epoch (00:00:00 UTC on 1 January 1970).

    time = Time.epoch_ms(981173106789) # => 2001-02-03 04:05:06.789 UTC
    time.millisecond                   # => 789

def self.new(year, month, day, hour = 0, minute = 0, second = 0, millisecond = 0, kind = Kind::Unspecified) #
def self.new(ticks : Int, kind = Kind::Unspecified) #
def self.new(time : LibC::Timespec, kind = Kind::Unspecified) #
def self.new(pull : JSON::PullParser) #
def self.new(pull : YAML::PullParser) #
def self.new #
def self.now : self #
def self.parse(time : String, pattern : String, kind = Time::Kind::Unspecified) : self #

Parses a Time in the given time string, using the given pattern (see `Time::Format`).

    Time.parse("2016-04-05", "%F") # => 2016-04-05 00:00:00

def self.utc_now : self #

## Class Method Detail

def self.days_in_month(year, month) : Int32 #
def self.leap_year?(year) : Bool #
def self.local_offset_in_minutes #

Returns the local time offset in minutes relative to GMT.

    # Assume in Argentina, where it's GMT-3
    Time.local_offset_in_minutes # => -180

def self.local_ticks #
def self.utc_ticks #

## Instance Method Detail

def +(other : Span) #
def +(other : MonthSpan) #
def -(other : Int) #
def -(other : Time) #
def -(other : Span) #
def -(other : MonthSpan) #
def <=>(other : self) #
def add_ticks(value) #
def at_beginning_of_day #
def at_beginning_of_hour #
def at_beginning_of_minute #
def at_beginning_of_month #
def at_beginning_of_quarter #
def at_beginning_of_semester #
def at_beginning_of_week #
def at_beginning_of_year #
def at_end_of_day #
def at_end_of_hour #
def at_end_of_minute #
def at_end_of_month #
def at_end_of_quarter #
def at_end_of_semester #
def at_end_of_week #
def at_end_of_year #
def at_midday #
def clone #
def date #
def day #
def day_of_week #
def day_of_year #
def epoch : Int64 #

Returns the number of seconds since the Epoch for this time.

    time = Time.parse("2016-01-12 03:04:05 UTC", "%F %T %z")
    time.epoch # => 1452567845

def epoch_f : Float64 #

Returns the number of seconds since the Epoch for this time, as a `Float64`.

    time = Time.parse("2016-01-12 03:04:05.678 UTC", "%F %T.%L %z")
    time.epoch_f # => 1452567845.678

def epoch_ms : Int64 #

Returns the number of milliseconds since the Epoch for this time.

    time = Time.parse("2016-01-12 03:04:05.678 UTC", "%F %T.%L %z")
    time.epoch_ms # => 1452567845678

def friday? #
def hash : Int64 #
def hour #
def inspect(io : IO) #
def kind #

Returns `Kind` of the instance.

def local? #

Returns `true` if `Kind` is set to Local.

def millisecond #
def minute #
def monday? #
def month #
def saturday? #
def second #
def sunday? #
def thursday? #
def ticks #
def time_of_day #
def to_json(json : JSON::Builder) #
def to_local #
def to_s(format : String, io : IO) #

Formats this time using the given format (see `Time::Format`) into the given io.

def to_s(format : String) : String #

Formats this time using the given format (see `Time::Format`).

    time = Time.new(2016, 4, 5)
    time.to_s("%F") # => "2016-04-05"

def to_utc #
def to_yaml(yaml : YAML::Builder) #
def tuesday? #
def utc? #

Returns `true` if `Kind` is set to Utc.

def wednesday? #
def year #