Skip to content
Jacob Quinn edited this page Jul 27, 2013 · 5 revisions

#####Periods

  • Period Functions

  • year, years,

  • month, months

  • week, weeks,

  • day, days

  • hour, hours

  • minute, minutes

  • second, seconds

  • periodfunction(x::Int64) ==> Period

  • Returns a Period type of the default Calendar (ISOCalendar) with value of x

  • Example: year(1) ==> 1 year

  • periodfunction(x::Period) ==> Period

  • Attemps to convert the input Period to the period type of the period function

  • Example: months(year(1)) ==> 12 months

  • zero(x::Type{Period}) ==> Period

  • Returns a Period type of the default Calendar (ISOCalendar) with value of 0

  • Example: zero(Year) ==> 0 years

  • one(x::Type{Period}) ==> Period

  • Returns a Period type of the default Calendar (ISOCalendar) with value of 1

  • Example: one(Year) ==> 1 year

#####Date Functions

  • date(y::Real, m::Real, d::Real) ==> Date
  • date(y::Year, m::Month, d::Day) ==> Date
  • Returns a Date with the given year (y), month (m), and day (d)
  • date(s::String) ==> Date
  • Tries to parse string s following the format "YYYY-MM-DD" to return a Date
  • Example: date("2011-05-01") ==> 2011-05-01
  • date(dt::DateTime) ==> Date
  • Truncates the DateTime type (dt) to a Date, ignoring any Hour, Minute, or Second value
  • today() ==> Date
  • Returns today's date
  • datetime(y::Real, m::Real, d::Real, h::Real, mi::Real, s::Real) ==> DateTime
  • datetime(y::Year, m::Month, d::Day, h::Hour, mi::Minute, s::Second) ==> DateTime
  • Returns a DateTime with the given year (y), month (m), day (d), hour (h), minute (mi), and second (s)
  • datetime(y::Real, m::Real, d::Real, h::Real, mi::Real, s::Real, tz::TimeZone) ==> DateTime
  • datetime(y::Real, m::Real, d::Real, h::Real, mi::Real, s::Real, tz::String) ==> DateTime
  • Returns a DateTime type with a given timezone alias or timezone string
  • Example datetime(2013,7,1,0,0,0,CST) ==> 2013-07-01T00:00:00 CDT
  • Example datetime(2013,7,1,0,0,0,"America/Chicago") ==> 2013-07-01T00:00:00 CDT
  • datetime(y::Real, m::Real, d::Real, h::Real, mi::Real, s::Real, off::Offset{n}) ==> DateTime
  • datetime(y::Real, m::Real, d::Real, h::Real, mi::Real, s::Real, offset(x::Period)) ==> DateTime
  • Returns a DateTime type with a given Offset{n} where {n} is the number of minutes difference from UTC
  • Example datetime(2013,7,1,0,0,0,Offset{-360}) ==> 2013-07-01T00:00:00 -06:00
  • Example datetime(2013,7,1,0,0,0,offset(hours(-6))) ==> 2013-07-01T00:00:00 -06:00
  • datetime(dt::Date) ==> DateTime
  • Adds hour(0), minute(0), and second(0) to the Date type (dt) to return a full DateTime type
  • now() ==> DateTime{UTC}
  • now(tz::TimeZone) ==> DateTime
  • now(off::Offsets) ==> DateTime
  • Returns the current instant as a DateTime type with timezone (tz) or offset (off)
  • unix2datetime(x::Real) ==> DateTime
  • Takes x as the number of seconds since Unix epoch (1970-01-01T00:00:00) and returns DateTime type
  • offset(x::Period...) ==> Offset{n}
  • Takes any number of Period arguments and returns an Offset{n} type where {n} is the number of minutes difference from UTC

#####Accessor/Date Functions All accessor/date functions work on Date or DateTime types

  • Accessor functions
  • year, month, day, hour, minute, second, millisecond
  • accessor(dt) ==> Int64
  • Returns the field value of the Date or DateTime for the given accessor function
  • isleap(dt) ==> Bool
  • Returns true if the year of a given Date/DateTime is a leap year
  • lastdayofmonth(dt) ==> Date/DateTime
  • Returns the last day of the month for a given Date or DateTime
  • dayofweek(dt) ==> Int64
  • Returns the day of the week as an integer with Monday == 1, ... Sunday == 7
  • dayofweekinmonth(dt) ==> Int64
  • Returns the count of the given Date/DateTime's day of week in the month; so a return value of 3 for a Wednesday indicates the 3rd Wednesday of the month
  • daysofweekinmonth(dt) ==> Int64
  • Returns the total number of the given day of week in the month; either 4 or 5
  • firstdayofweek(dt) ==> Date/DateTime
  • Returns the Date/DateTime of the first day of the current week
  • lastdayofweek(dt) ==> Date/DateTime
  • Returns the Date/DateTime of the last day of the current week
  • dayofyear(dt) ==> Int64
  • Returns the day of the year of the given Date/DateTime
  • isdate(dt) ==> Bool
  • Returns true if dt is a Date type
  • isdatetime(dt) ==> Bool
  • Returns true if dt is a DateTime type

#####Exported Constants

Days of the week and months of the year are exported constants to be used with date range creation through patterns (anonymous boolean functions).

  • Days of the week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
  • Days of week abbreviated: Mon, Tue, Wed, Thu, Fri, Sat, Sun
  • Months of the year: January, February, March, April, May, June, July, August, September, October, November, December
  • Months abbreviated: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
Clone this wiki locally