Skip to content

Commit

Permalink
Change nowutc() to now(Dates.UTC()) for a better API with TimeZones.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Aug 27, 2014
1 parent 444fafe commit a956d75
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions base/Dates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ include("dates/io.jl")

export Period, DatePeriod, TimePeriod,
Year, Month, Week, Day, Hour, Minute, Second, Millisecond,
TimeType, DateTime, Date,
TimeZone, UTC, TimeType, DateTime, Date,
# accessors.jl
yearmonthday, yearmonth, monthday, year, month, week, day,
hour, minute, second, millisecond, dayofmonth,
Expand All @@ -26,7 +26,7 @@ export Period, DatePeriod, TimePeriod,
July, August, September, October, November, December,
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec,
# conversions.jl
unix2datetime, datetime2unix, now, nowutc, today,
unix2datetime, datetime2unix, now, today,
rata2datetime, datetime2rata, julian2datetime, datetime2julian,
# adjusters.jl
firstdayofweek, lastdayofweek,
Expand Down
2 changes: 1 addition & 1 deletion base/dates/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function now()
return DateTime(tm.year+1900,tm.month+1,tm.mday,tm.hour,tm.min,tm.sec)
end
today() = Date(now())
nowutc() = unix2datetime(time())
now(::Type{UTC}) = unix2datetime(time())

rata2datetime(days) = DateTime(yearmonthday(days)...)
datetime2rata(dt::DateTime) = days(dt)
Expand Down
3 changes: 3 additions & 0 deletions base/dates/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ abstract Calendar <: AbstractTime
# ISOCalendar provides interpretation rules for UTInstants to civil date and time parts
immutable ISOCalendar <: Calendar end

abstract TimeZone
immutable UTC <: TimeZone end

# TimeTypes wrap Instants to provide human representations of time
abstract TimeType <: AbstractTime

Expand Down
2 changes: 1 addition & 1 deletion test/dates/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@

@test typeof(Dates.now()) <: Dates.DateTime
@test typeof(Dates.today()) <: Dates.Date
@test typeof(Dates.nowutc()) <: Dates.DateTime
@test typeof(Dates.now(Dates.UTC)) <: Dates.DateTime

0 comments on commit a956d75

Please sign in to comment.