53

The short answer is, yes! There is a whole undocumented package TemporalData` containing some useful functions. The results below are from my own spelunking. Feel free to add/amend as appropriate. Let's set up some simple TemporalData objects to explore them: fakedata = Transpose@{DatePlus[{2001, 1}, {#, "Month"}] & /@ Range[0, 99], ...


41

It took me quite a while, but finally, here's a visualization of the perigee of Flamsteed's comet: I should first note two things: first, some of the needed data for computing the orbit of comet C/1683 O1 was missing in AstronomicalData["CometC1683O1", "Properties"], and I had to pull information from external sources to supplement the information available;...


38

Date-picker implementation in Mathematica The following is my implementation of a simple date-picker. The current date is highlighted in LightBlue and the weekends are highlighted in LightGreen. The selected date is always highlighted in LightRed (the default selection is the current date). You can tap into this calendar by using the Dynamic values for year, ...


38

Indeed, this functionality still exists, but it has been moved into its own package. Load the package: Needs["aBetterProgrammer`"] You will have access to such functions as GimmeDaCodez (answers any nebulous MMA.SE question by guessing the unspoken needs of the asker) WizardForm (an output wrapper; produces perfectly terse code; all function calls are ...


22

Since version 11 most commands finally support the Interpretation option: Interpretation -> "Literal" being the classical (default) way of operation, and Interpretation -> "Guess" using advanced machine learning to get much better results than ReadProgrammerIntentions ever achieved. Makes programming a lot easier. You can emulate the old behavior with ...


22

I tend to use a pattern matching approach: myCode/.{x_?BugQ:>BugStrip[x],x_?TypoQ:>Detypo[x],x_?WrongSignQ:>-x,x_?OffBy2PiQ:>x*2\[Pi]} With the usual caveat that pattern matching can be slower than other methods, but conceptually easier to understand. Hopefully someone will aggregate the answers to compare performance. Good luck!


20

There is a built-in DateSetter: {Developer`DateSetter[Dynamic@date], Dynamic@date} By default the first selectable date is tomorrow and one can only go to future months. However, the option NotebookTools`DateSetterRange can be used to set the first selectable date to sometime in the past, {Developer`DateSetter[Dynamic@date, NotebookTools`DateSetterRange -&...


18

This function was deprecated in V4.2, being succeeded by CellularAutomaton. Since your answer is hidden somewhere in rules like 110, why reinvent the wheel with ReadProgrammerIntentions?


16

The reason for the result of DateDifference[{2015, 4, 1}, {2015, 10, 1}, "Year"] (* Quantity[0.5, "Years"] *) is that 2016 is a leap year, so there are 366 days in the year between {2015, 4, 1} and {2016, 4, 1}. Therefore we get 183/366 or exactly 1/2 back. Note also the documented DayCountConvention option, DateDifference[{2015, 4, 1}, {2015, 10, 1}, "...


16

Building off the other answer, CountryData has the data for the time zones for each country, as well as their population. So we can split each country proportionally into its individual timezones: countries = CountryData[]; populations = CountryData[#, "Population"] & /@ countries; timeZones = CountryData[#, "TimeZones"] & /@ countries; data = ...


14

As of Mathematica 10.1, creating a timeline is built-in with TimelinePlot[]. TimelinePlot[{ Labeled[Interval[{DateObject[{2010, 2, 1}], DateObject[{2013, 5, 4}]}], "label1"], Labeled[DateObject[{2012, 4, 6}], "label2"], Labeled[Interval[{DateObject[{2011, 3, 1}], DateObject[{2012, 12, 21}]}], "label3"] }] Lots of possibilities, looking at ...


14

I would do this with rule replacement. First, you want to have a list of the days of the week in the appropriate order: days = DayName@{0, 0, #} & /@ Range[5, 11]; Then, you can take tallied results and turn them into a list of rules: tallied = {{Tuesday, 533}, {Sunday, 487}, {Saturday, 481}, {Friday, 422}, {Thursday, 353}, {Wednesday, 371}}; ...


14

For full ranges There is the function DayRange that can be used for this purpose, but not in the same simple way like CharacterRange. For the days: DayName /@ DayRange[Today, Today ~DatePlus~ {{1, "Week"}, {-1, "Day"}}] {Wednesday, Thursday, Friday, Saturday, Sunday, Monday, Tuesday} For the months: DateValue[#, "MonthName"] & /@ DayRange[Today, ...


14

There's a couple ways to do this: data = {{{2014, 8, 4, 10, 36, 0.}, 257.}, {{2014, 8, 4, 16, 28, 0.}, 385.}, {{2014, 8, 4, 22, 53, 0.}, 176.}, {{2014, 8, 5, 6, 52, 0.}, 148.}, {{2014, 8, 5, 11, 19, 0.}, 192.}}; 1) Convert dates to absolute times: data[[All, 1]] = AbsoluteTime /@ data[[All, 1]]; f1 = Interpolation@data; f1[AbsoluteTime@{2014,8,4,10,40}]...


14

This is how you can get the last 30 weekdays starting from yesterday: days = DayRange[DayPlus[Yesterday, -30], Yesterday, "Weekday"] To get {y,m,d} vectors, we might use Take[#, 3] &@*DateList /@ days Regarding the time zone, the only problem I can see would be that Yesterday will not produce the right result around midnight. To check this I used the ...


14

Instead of FindFit[], DistributionFitTest[] is the function to use to test the distribution followed by your data. Using easter[] from this answer, generate the number of days Easter is counted from March 23 of that same year: data = Table[DayCount[DateObject[{k, 3, 23}], DateObject[easter[k]]], {k, 1700, 2018}]; Then, hh = DistributionFitTest[data // N, ...


14

I worked on this problem in 2015. Here is part on my notebook from that time. A not so good algorithm. friday13th[year_Integer] := Select[DayName[#] === Friday &] @ DateRange[DateObject[{year, 1, 13}], DateObject[{year, 12, 13}], {1, "Month"}] A good algorithm. friday13th[year_Integer] := Select[DayName[#] === Friday &] @ Table[...


13

Using Simon's data: In[6]:= datelist = {"29/02/2008", "15/12/2007", "06/09/2007", "06/10/2008", "05/03/2007", "24/01/2010", "19/06/2009", "03/11/2009", "02/02/2010", "25/12/2009"}; We can just sort the data by the absolute time: In[7]:= SortBy[datelist, AbsoluteTime[{#, {"Day", "Month", "Year"}}] &] Out[7]= {"05/03/2007", "06/09/2007", "15/12/...


13

For those with v. 10, here's one way. I didn't overlap the bars because it looks nicer this way, imho. schedule[{t1_, t2_}, {t3_, t4_}] := Module[{convert, ts = Flatten[{{t1, t2}, {t3, t4}}, 1][[All, 1]], hours}, convert[{h_, min_}] := h + min/60; hours = Range[Min[ts] - 1, Max[ts] + 1]; NumberLinePlot[{ convert[t1] < x < convert[t2], ...


13

Updated This happens because your DynamicModule returns a dynamic object of which x is passed on to the front-end before the scheduled task starts, so the front-end-x cannot be modified anymore by any process (more details at the end). The problem can be further simplified. This works: RemoveScheduledTask@ScheduledTasks[]; DynamicModule[{x = 0}, ...


13

Another, shorter way is Append[d, t] From the docs, DateObject[date,time] represents the specified date list and TimeObject time. If you need the list you mention in the question, just convert the DateObject using DateList: DateList@Append[d, t] (* {2012, 6, 11, 14, 1, 45.} *)


12

Based on data in Comm ACM. This took a while to only partially automate, largely through a helper function that spreads out the years: diffuse[a_][years_List] := Module[{x0 = 1, x1 = Length[years], y0 = Min[years], y1 = Max[years]}, years // MapIndexed[ {#1, (((y1 - y0)/(x1 - x0))*(First[#2] - x0) + y0) a + (#1) (1 - a)} &]]; ...


12

Here is one that should work in version 6 and later. The full code is at bottom. Here is what it looks like: {dateSetter[Dynamic[d]],Dynamic[d]} I did not incorporate the year here, but you could put it in a Tooltip or add it to the button's graphic. And when you click on the button you get Incorporate this into a Manipulate using {d,dateSetter[#]&} ...


12

A simple string-based approach is to swap the order of day/month/year, do the Sort and then swap back again: (* Example data *) datelist = DateString[# + AbsoluteTime[{2007, 01, 01}], {"Day", "/", "Month", "/", "Year"}] & /@ RandomInteger[10^8, 10] {"29/02/2008", "15/12/2007", "06/09/2007", "06/10/2008", "05/03/2007", "24/01/2010", "19/06/2009",...


12

data = Cases[DayRange[{2000, 1, 1}, {2399, 12, 31}, Friday], {y_, m_, d_} :>d] // Tally // Sort; TableForm[data[[ ;; ;; 2]], TableHeadings -> {None, {"Day", "Number of Fri."}}] (Reverse@SortBy[data, Last])[[;; 5]] {{27, 688}, {20, 688}, {13, 688}, {6, 688}, {25, 687}}


12

Two solutions: Use the listability of Interpreter to parallelize calls to WR servers: In[1]:= AbsoluteTiming[Interpreter["Time"][timeData]] // First Out[1]= 6.551647 Use Structured interpreters to avoid calling WR servers altogether: In[2]:= AbsoluteTiming[Interpreter["StructuredTime"][timeData]] // First Out[2]= 0.165715 In general you might want ...


12

TimeObject can take a DateObject so: datetime = DateObject[] time = TimeObject[datetime]


12

You could inject the value once with a Function instead of With. Cases[RandomInteger[{AbsoluteTime["2001"], AbsoluteTime["2003"]}, 1000], a_ /; a > #] &@ AbsoluteTime["2002"] In V10, we can use named arguments, which is arguably [sic] more readable (and more typing): Cases[RandomInteger[{AbsoluteTime["2001"], AbsoluteTime["2003"]}, 1000], ...


12

The date is different because Wolfram Alpha is wrong about when the Battle of Agincourt took place. Alpha is returning 25 October 1415 in the Gregorian calendar as the date of the battle, but the battle took place on that date in the Julian calendar (the calendar in use at the time). That date corresponds 3 November 1415 in the proleptic Gregorian ...


12

Using Mr Wizard's data the complete list of away days is away = Join @@ DateRange @@@ Reverse @ data; The 540th most recent absence, plus 10 years is: away[[-540]] + {10, 0, 0} (* {2017, 9, 2} *)


Only top voted, non community-wiki answers of a minimum length are eligible