-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Date/DateTime support through the Time module #5328
Closed
Closed
Changes from 8 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
d2a6da9
Add Datetime/Date support through the Time module
quinnj bb9ceee
Include Time module in Base bootup
quinnj b85d96e
Fix missing precision import in Time module
quinnj 9e353c6
Add Time module exports to exports.jl
quinnj 467dff8
Fix failing travis builds
quinnj 14f19e3
Reduce Time exports
quinnj d26795a
Only export Date/Datetime
quinnj 7cad41f
Remove old CALENDAR/TIMEZONE consts
quinnj 3b450fc
Fix a typo
quinnj 5778218
Change ISOCalendar/UTC to immutable types to prevent subtyping
quinnj f54fb8a
General code cleanup. Move typealiases together. Clean up function si…
quinnj ea9c2bc
Remove DatetimeRange support for now. Reworked recur() to be stand-al…
quinnj a0a2276
Add single argument Date string parsing.
quinnj 0ecad4f
Remove DatetimeRange tests
quinnj 9f12b1b
Make Period type definitions safer by providing only ::Real inner con…
quinnj 048ef5f
Add in reworked timezone functionality
quinnj be61ca8
Remove leaps.jl in favor of time/leapsinfo.jl
quinnj d2db45a
Update Time tests
quinnj 39ae13b
Change Offset{n} to Offset with field n
quinnj dc8486d
Add leapseconds.jl file
quinnj 4591a71
Add a bunch more tests
quinnj 98191dd
Add UTCTimezone type and make UTC an instance. Timezones are now base…
quinnj 2936704
Restrict Period constructors to Integer. This forces the user to spec…
quinnj 1a30cdb
Update core date alogrithms to be more robust for large negative date…
quinnj d75b342
Formatting issues
quinnj e3cbbc4
Rework firstdayofweek and lastdayofweek that now pass all tests
quinnj af6315c
Add keyword to recur to specify an exclusion function.
quinnj 5238a19
Add Datetime with Periods constructor.
quinnj b782e1e
Few updates in the date parsing functions
quinnj ae7e7f6
Remove timezone functionality
quinnj d68a0b8
Update time.jl tests
quinnj ce0a172
Add missing time/leapsinfo.jl file. This is an auto-generated file th…
quinnj 6772471
Move leapsinfo to base instead of test. Should fix travis build.
quinnj e6eabb4
Change Datetime => DateTime and Timezone => TimeZone
quinnj 8716a63
Parsing improvements
quinnj 6e9a0f1
Clean up Period conversions
quinnj 1cc27d5
Initial whack at documentation
quinnj 90dce0c
Update Time module tests
quinnj f99882d
Fix export Datetime => DateTime
quinnj 6383218
Fix failing tests
quinnj 6ef6e5b
Remove all time zone functionality.
quinnj 773e963
Update time.jl tests
quinnj 043f724
Update documentation. Add function reference and parsing examples.
quinnj dd271c9
Remove extra whitespace
quinnj b6d9745
Throw ArgumentError for out of range month arguments to Date/DateTime
quinnj 82220b2
A few more ArgumentError throws
quinnj 53611b8
Add convert_to_leapsecond keyword argument to unix2date to allow user…
quinnj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Two leap-second arrays | ||
# SETLEAPS is used when calculating the # of leap seconds from inputs | ||
# GETLEAPS represents the leap second instant in a timeline that includes leap seconds | ||
const SETLEAPS = [62214480000000,62230377600000,62261913600000,62293449600000,62324985600000, | ||
62356608000000,62388144000000,62419680000000,62451216000000,62498476800000, | ||
62530012800000,62561548800000,62624707200000,62703676800000,62766835200000, | ||
62798371200000,62845632000000,62877168000000,62908704000000,62956137600000, | ||
63003398400000,63050832000000,63271756800000,63366451200000,63476784000000] | ||
const GETLEAPS = [62214480000000,62230377601000,62261913602000,62293449603000,62324985604000, | ||
62356608005000,62388144006000,62419680007000,62451216008000,62498476809000, | ||
62530012810000,62561548811000,62624707212000,62703676813000,62766835214000, | ||
62798371215000,62845632016000,62877168017000,62908704018000,62956137619000, | ||
63003398420000,63050832021000,63271756822000,63366451223000,63476784024000] | ||
|
||
macro leapsunroll(a,r,var) | ||
A = eval(a) | ||
R = eval(r) | ||
ret = Expr(:block) | ||
push!(ret.args,:($var < $(A[1]) && return 0)) | ||
push!(ret.args,:($var >= $(A[end]) && return $(endof(A)*1000))) | ||
push!(ret.args,searchsortedfirsttree(A[2:(endof(A)-1)],R,var)) | ||
return ret | ||
end | ||
# Recursively build binary search tree w/ known lookup values | ||
# A is sorted array of lookup values | ||
# R is return values for each index of A | ||
# i.e. R[1] is returned for values < A[1], R[2] for < A[2], etc. | ||
function searchsortedfirsttree(A,R,var) | ||
l = length(A) | ||
mid = iseven(l) ? l>>>1 : (l>>>1)+1 | ||
if mid == 1 | ||
if l == 1 | ||
return :($var < $(A[1]) ? $(R[1]) : $(R[2])) | ||
else # l == 2 | ||
return :($var < $(A[1]) ? $(R[1]) : | ||
$var < $(A[2]) ? $(R[2]) : $(R[3])) | ||
end | ||
end | ||
iftree = Expr(:if) | ||
iftree.args = Array(Any,3) | ||
iftree.args[1] = :($var < $(A[mid])) # condition | ||
iftree.args[2] = searchsortedfirsttree(A[1:mid-1],R[1:mid],var) | ||
iftree.args[3] = searchsortedfirsttree(A[mid+1:end],R[mid+1:end],var) | ||
return iftree | ||
end | ||
function setleaps(ms) | ||
@leapsunroll(SETLEAPS,[1000:1000:((endof(SETLEAPS)-1)*1000)],ms) | ||
end | ||
function setleapsecond(ms) | ||
@leapsunroll([SETLEAPS[i]+1000 for i = 1:length(SETLEAPS)], | ||
[1000:1000:((endof(SETLEAPS)-1)*1000)],ms) | ||
end | ||
function getleaps(ms) | ||
@leapsunroll(GETLEAPS,[1000:1000:((endof(SETLEAPS)-1)*1000)],ms) | ||
end | ||
function getleapsecond(ms) | ||
@leapsunroll([GETLEAPS[i]+1000 for i = 1:length(GETLEAPS)], | ||
[1000:1000:((endof(SETLEAPS)-1)*1000)],ms) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this could be more generalized and live in the sort.jl file or if it's special-cased enough to just stay here. It's not really Datetime specific. It could probably also use a better name.