Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Dec 2, 2014
2 parents 9be7ba7 + bc02866 commit bf57363
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 65 deletions.
1 change: 0 additions & 1 deletion ARM.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ override USE_BLAS64=0

override LLVM_VER=3.5.0

override USE_SYSTEM_LIBM=1
override USE_SYSTEM_FFTW=1
override USE_SYSTEM_GMP=1
override USE_SYSTEM_MPFR=1
4 changes: 1 addition & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ environment:
# USEMSVC: "1"
matrix:
- ARCH: "i686"
MARCH: "pentium4"
- ARCH: "x86_64"
MARCH: "x86-64"

# Only build on master and PR's for now, not personal branches
# Whether or not PR's get built is determined in the webhook settings
branches:
only:
- master
# TODO: - release-0.3
- release-0.3

clone_depth: 50

Expand Down
6 changes: 0 additions & 6 deletions base/dates/arithmetic.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# Instant arithmetic
for op in (:+,:*,:%,:/)
@eval ($op)(x::Instant,y::Instant) = throw(ArgumentError("Operation not defined for Instants"))
end
(+)(x::Instant) = x
(-){T<:Instant}(x::T,y::T) = x.periods - y.periods

# TimeType arithmetic
for op in (:+,:*,:%,:/)
@eval ($op)(x::TimeType,y::TimeType) = throw(ArgumentError("Operation not defined for TimeTypes"))
end
(+)(x::TimeType) = x
(-){T<:TimeType}(x::T,y::T) = x.instant - y.instant

Expand Down
10 changes: 3 additions & 7 deletions base/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ value{P<:Period}(x::P) = x.value
# P(x) = new((convert(Int64,x))
# The following definitions are for Period-specific safety
for p in (:Year,:Month,:Week,:Day,:Hour,:Minute,:Second,:Millisecond)
# This ensures that we can't convert between Periods
@eval $p(x::Period) = throw(ArgumentError("Can't convert $(typeof(x)) to $($p)"))
# Unless the Periods are the same type
@eval $p(x::$p) = x
# Convenience method for show()
@eval _units(x::$p) = $(" " * lowercase(string(p))) * (abs(value(x)) == 1 ? "" : "s")
# periodisless
Expand Down Expand Up @@ -43,9 +39,6 @@ Base.isless{R<:Real}(y::R,x::Period) = isless(int64(y),value(x))
=={R<:Real}(x::Period,y::R) = ==(int64(y),value(x))
=={R<:Real}(y::R,x::Period) = ==(int64(y),value(x))

Base.isless(x::Period,y::Period) = throw(ArgumentError("Can't compare $(typeof(x)) and $(typeof(y))"))
==(x::Period,y::Period) = throw(ArgumentError("Can't compare $(typeof(x)) and $(typeof(y))"))

#Period Arithmetic:
import Base.div, Base.mod, Base.gcd, Base.lcm
let vec_ops = [:.+,:.-,:.*,:.%,:div]
Expand Down Expand Up @@ -107,9 +100,12 @@ Base.show(io::IO,x::CompoundPeriod) = print(io,string(x))
# E.g. Year(1) + Day(1)
(+)(x::Period,y::Period) = CompoundPeriod(sort!(Period[x,y],rev=true,lt=periodisless))
(+)(x::CompoundPeriod,y::Period) = (sort!(push!(x.periods,y) ,rev=true,lt=periodisless); return x)
(+)(y::Period,x::CompoundPeriod) = x + y
# E.g. Year(1) - Month(1)
(-)(x::Period,y::Period) = CompoundPeriod(sort!(Period[x,-y],rev=true,lt=periodisless))
(-)(x::CompoundPeriod,y::Period) = (sort!(push!(x.periods,-y),rev=true,lt=periodisless); return x)
(-)(x::CompoundPeriod) = CompoundPeriod(-x.periods)
(-)(y::Period,x::CompoundPeriod) = (-x) + y

# Capture TimeType+-Period methods
(+)(a::TimeType,b::Period,c::Period) = (+)(a,b+c)
Expand Down
33 changes: 10 additions & 23 deletions base/dates/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,17 @@ abstract Period <: AbstractTime
abstract DatePeriod <: Period
abstract TimePeriod <: Period

immutable Year <: DatePeriod
value::Int64
end
immutable Month <: DatePeriod
value::Int64
end
immutable Week <: DatePeriod
value::Int64
end
immutable Day <: DatePeriod
value::Int64
end

immutable Hour <: TimePeriod
value::Int64
end
immutable Minute <: TimePeriod
value::Int64
end
immutable Second <: TimePeriod
value::Int64
for T in (:Year,:Month,:Week,:Day)
@eval immutable $T <: DatePeriod
value::Int64
$T(v::Number) = new(v)
end
end
immutable Millisecond <: TimePeriod
value::Int64
for T in (:Hour,:Minute,:Second,:Millisecond)
@eval immutable $T <: TimePeriod
value::Int64
$T(v::Number) = new(v)
end
end

# Instant types represent different monotonically increasing timelines
Expand Down
13 changes: 8 additions & 5 deletions contrib/windows/msys_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ case $(uname) in
;;
esac

# set MARCH for consistency with how binaries get built
if [ "$ARCH" = x86_64 ]; then
echo "override MARCH = x86-64" >> Make.user
else
echo "override MARCH = i686" >> Make.user
echo "override JULIA_CPU_TARGET = pentium4" >> Make.user
fi

curlflags="curl --retry 10 -k -L -y 5"

# Download most recent Julia binary for dependencies
Expand Down Expand Up @@ -99,11 +107,6 @@ if [ -z "$USEMSVC" ]; then
else
echo "override USEMSVC = 1" >> Make.user
echo "override ARCH = $ARCH" >> Make.user
if [ $ARCH = x86_64 ]; then
echo "override MARCH = x86-64" >> Make.user
else
echo "override MARCH = $ARCH" >> Make.user
fi
echo "override XC_HOST = " >> Make.user
export CC="$PWD/deps/libuv/compile cl -nologo -MD -Z7"
export AR="$PWD/deps/libuv/ar-lib lib"
Expand Down
2 changes: 1 addition & 1 deletion deps/openlibm
Submodule openlibm updated from 0b9d67 to 3ee2a6
29 changes: 10 additions & 19 deletions test/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ ms = Dates.Millisecond(1)
@test mi == mi
@test s == s
@test ms == ms
@test_throws ArgumentError y != m
@test_throws ArgumentError m != w
@test_throws ArgumentError w != d
@test_throws ArgumentError d != h
@test_throws ArgumentError h != mi
@test_throws ArgumentError mi != s
@test_throws ArgumentError s != ms
@test_throws ArgumentError ms != y
y2 = Dates.Year(2)
@test y < y2
@test y2 > y
Expand Down Expand Up @@ -116,13 +108,13 @@ y2 = Dates.Year(2)
@test Dates.Year(false) != y
@test_throws MethodError Dates.Year(:hey) == y
@test Dates.Year(real(1)) == y
@test_throws ArgumentError Dates.Year(m) == y
@test_throws ArgumentError Dates.Year(w) == y
@test_throws ArgumentError Dates.Year(d) == y
@test_throws ArgumentError Dates.Year(h) == y
@test_throws ArgumentError Dates.Year(mi) == y
@test_throws ArgumentError Dates.Year(s) == y
@test_throws ArgumentError Dates.Year(ms) == y
@test_throws MethodError Dates.Year(m) == y
@test_throws MethodError Dates.Year(w) == y
@test_throws MethodError Dates.Year(d) == y
@test_throws MethodError Dates.Year(h) == y
@test_throws MethodError Dates.Year(mi) == y
@test_throws MethodError Dates.Year(s) == y
@test_throws MethodError Dates.Year(ms) == y
@test Dates.Year(Dates.Date(2013,1,1)) == Dates.Year(2013)
@test Dates.Year(Dates.DateTime(2013,1,1)) == Dates.Year(2013)
@test typeof(y+m) <: Dates.CompoundPeriod
Expand All @@ -133,8 +125,8 @@ y2 = Dates.Year(2)
@test typeof(y+mi) <: Dates.CompoundPeriod
@test typeof(y+s) <: Dates.CompoundPeriod
@test typeof(y+ms) <: Dates.CompoundPeriod
@test_throws ArgumentError y > m
@test_throws ArgumentError d < w
@test_throws MethodError y > m
@test_throws MethodError d < w
@test typemax(Dates.Year) == Dates.Year(typemax(Int64))
@test typemax(Dates.Year) + y == Dates.Year(-9223372036854775808)
@test typemin(Dates.Year) == Dates.Year(-9223372036854775808)
Expand Down Expand Up @@ -262,8 +254,7 @@ test = ((((((((dt + y) - m) + w) - d) + h) - mi) + s) - ms)
@test 1 == Dates.Millisecond(1)
@test (Dates.Millisecond(1) < 1) == false
@test (1 < Dates.Millisecond(1)) == false
@test_throws ArgumentError Dates.Year(1) < Dates.Millisecond(1)
@test_throws ArgumentError Dates.Year(1) == Dates.Millisecond(1)
@test_throws MethodError Dates.Year(1) < Dates.Millisecond(1)

@test Dates.Year("1") == y
@test Dates.Month("1") == m
Expand Down

0 comments on commit bf57363

Please sign in to comment.