Tag Info

New answers tagged

0

I am not sure I understand the constraints of this question if there are any. But would this work: Map[ Function[ DateString[DatePlus[ DateList[{ToExpression[StringTake[ToString[#1], 4]], 1, 1}], {(ToExpression[StringTake[ToString[#1], -3]] - 1), "Day"}], {"Year", "Month", "Day"}]], dateslalala]


3

Perhaps, using: dateslalala={2003364, 2003157, 2003314, 2003302, 2003181, 2003062, 2003254, \ 2003070, 2003365, 2003338, 2003233, 2003073, 2003020, 2003010, \ 2003238, 2003107, 2003310, 2003347, 2003204, 2003066, 2005364, \ 2005157, 2005314, 2005302, 2005181, 2005062, 2005254, 2005070, \ 2005365, 2005338, 2005233, 2005073, 2005020, 2005010, 2005238, \ ...


1

The thought is DatePlus. split[x_Integer] := {{FromDigits@#[[1 ;; 4]], 1, 1}, FromDigits@#[[5 ;; -1]]} &@IntegerDigits[x] split[2003305] (* {{2003,1,1},305} *) DatePlus[split[2003305][[1]], 305] (* {2003,11,2} *) f = Block[{$DateStringFormat = {"Year", "Month", "Day"}, res}, res = split[#]; DatePlus[res[[1]], res[[2]] - 1]] ...


3

Lest we forget the old-fashined ways: extremes=data[[Ordering[# data[[All,2]],1][[1]]&/@{-1,1}]]; DateListPlot[{data,##&@@(List/@extremes)}, Joined -> {True,False,False}, BaseStyle -> PointSize[Large], PlotStyle -> {Gray,Red, Green}, PlotLegends -> {"data", "max","min"}] Note: If data is not sorted, we need to sort it first ...


3

Do you care about maxima and minima or peaks? If peaks then you could use FindPeaks but this is only available for M10+. Note also that FindPeaks only handles regularly spaced TimeSeries - hence the use of TemporalRegularity: data = TimeSeries[{{{2015, 3, 25}, 130}, {{2015, 3, 26}, 132}, {{2015, 3, 27}, 132}, {{2015, 3, 30}, 133}, {{2015, 3, 31}, 132}, ...


8

Perhaps a bit more elegant than Sjoerd's approach: data = Sort @ data; (* address Sjoerd's concern *) pts = { data, MinimalBy[data, Last, 1], MaximalBy[data, Last, 1] }; DateListPlot[pts, Joined -> {True, False, False}, PlotStyle -> {Automatic, Red, Green} ]


4

Haven't aimed for efficiency or elegance but for 'straightforwardness' data = Sort@data; (* just to make sure the dates are always sorted *) max = Max@data[[All, 2]]; min = Min@data[[All, 2]]; maxPos = FirstPosition[data[[All, 2]], max] // First; minPos = FirstPosition[data[[All, 2]], min] // First; maxPlotPos = MapAt[AbsoluteTime, data[[maxPos]], 1]; ...


1

The option value is ignored because DateListPlot calls Graphics`DateListPlotDump`iDateListPlot which only uses Options for these items: {PlotRange, AxesOrigin, GridLines, GridLinesStyle, Epilog, Prolog, Frame, Axes, Ticks, FrameTicks, DateTicksFormat, DateFunction, DataRange, PlotRangePadding, PlotLegends, PlotStyle, PlotMarkers, Joined, BaseStyle, ...


1

A variant of Pickett's answer: using new-in-10 RegionMember with a terse way to extract the plot range extended to either Line or Point data written as a reusable function Code: inrangeData[gr_Graphics] := Select[Rectangle @@ (PlotRange[gr]\[Transpose]) // RegionMember] /@ Cases[Normal @ gr, _Point | _Line, -1][[All, 1]] Test: ...


1

Use DateList or DateString, depending on desired output: DateList[3345091200] (* {2006, 1, 1, 8, 0, 0.} *) DateString[3345091200] (* "Sun 1 Jan 2006 08:00:00" *) Edit: to use this in your specific example, you could do something like this: Export["UbShift2.txt", Append[DateList[#[[1]]], QuantityMagnitude[#[[2]]]] & /@ shifted["Path"]]


0

You may consider this: DateListPlot[{{1, 1, 2, 3, 5, 8, 11}, {5, 8, 9, 6, 2, 4, 7}}, {2013,1,1}, Joined -> True, CoordinatesToolOptions -> {"DisplayFunction" -> (DateString@First@# &)}] Then let's try this: SetOptions[DateListPlot, CoordinatesToolOptions -> {"DisplayFunction" -> (DateString@First@# &)}]; DateListPlot[{{1, 1, ...


3

See AbsoluteTime... e.g. AbsoluteTime[{1999,1,1}] returns the number of seconds from 1st Jan 1970 to that date. In full... Fit[{AbsoluteTime[#1] - AbsoluteTime[{1991, 4, 1}], #2} & @@@ {{{1991, 4, 1}, 100}, {{1991, 4, 1}, 110}, {{1993, 6, 1}, 120}, {{1994, 4, 1}, 129}, {{1996, 4, 10}, 130}, {{1999, 2, 2}, 140}, {{2004, 4, 6}, 150}, ...


1

Night time of First day + (night time period times [[2;;-2]] days) + night time of Last day nightTime[{startDateTime_?DateObjectQ, endDateTime_?DateObjectQ}, {nightStartTime_?TimeObjectQ, nightEndTime_?TimeObjectQ}] := (* night time of First day + night time period \[Times] [[2;;-2]] \days + night time of Last day *) Simplify[ ...


3

d1 = {2015, 4, 1, 3, 10}; d2 = {2015, 4, 3, 18, 10}; j[d_, s_, h_] := Join[DatePlus[d, s][[1 ;; 3]], {h, 00}] abst = AbsoluteTime; l1 = DateRange[j[d1, -2, 22], j[d2, 2, 22]]; l2 = DateRange[j[d1, -1, 6], j[d2, 3, 6]]; ints = Interval /@ Map[abst, Transpose@{l1, l2}, {2}]; iu = IntervalUnion@@(IntervalIntersection[Interval[abst/@{d1,d2}], #] & /@ ints); ...


1

Edit, fixing some errors to show this "works" tend = AbsoluteTime[{2015, 4, 3, 18, 10}]; deltimed = (tend - AbsoluteTime[{2015, 4, 1, 3, 10}])/3600/24; {wholedays, fractionseconds} = {Floor[#], FractionalPart[#] 24 3600 } & @ deltimed; isnight[t_?NumericQ] := Boole[0 <= # < 6 || # >= 22] &@DateList[t][[4]]; nightfirstpartday = ...


1

In it's current form TimeObject always refers to a specific moment in time with an explicit TimeZone value. An alternative representation for what you have, in terms of HMS without any local/timezone would be a MixedRadixQuantity representing a duration since midnight: MixedRadixQuantity[{0, 15, 14}, {"Hours", "Minutes", "Seconds"}] Though this is not a ...


3

fixed in 10.1 code times = {TimeObject[List[0, 14, 55.99`]], TimeObject[List[0, 14, 57.8`]], TimeObject[List[0, 14, 59.09`]], TimeObject[List[0, 14, 59.11`]], TimeObject[List[0, 14, 59.12`]], TimeObject[List[0, 14, 59.14`]], TimeObject[List[0, 14, 59.4`]], TimeObject[List[0, 14, 59.44`]], TimeObject[List[0, 14, 59.45`]], ...


2

In version 10.1, try this: Manipulate[ TimelinePlot[ {Interval[{ToString[myBegin], ToString[myEnd]}] -> "My range"}, PlotRange -> {DateObject[{1940}], DateObject[{2020}]}, Ticks -> {DateRange["1940", "2020", Quantity[5, "Years"]]} ], {{myBegin, 1950, "Begin"}, 1950, 2014, 1}, {{myEnd, 1960, "End"}, myBegin, 2015, 1}]


4

You will need work with an interval slider in terms of AbsoluteTime values because such sliders only work with numeric objects. Here is a demonstration where a interval slider has the behavior you want. With[{ min0 = AbsoluteTime @ DateObject[{2015, 3, 8, 10, 0, 0.}], max0 = AbsoluteTime @ DateObject[{2015, 3, 8, 12, 30, 0.}], minT = AbsoluteTime @ ...


2

Select[DayPlus[DateList[TimeZone -> 2], #] & /@ Range[-30, -1], (! DayMatchQ[#, "Weekend"] &)] I live in Germany TimeZone -> 2 is the correct Timezone for summertime and in winter i goes you have to take TimeZone-> 1 If you run the Kernel from Germany $TimeZone should always have the correct value (Summer and Wintertime) so i suggest to ...


12

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 ...


2

As shown inthe documentation, the third parameter of DateValue provides control of the form of the value returned. If you want a String specify that. DateValue[{2014, 4, 12}, "DayName", String] "Saturday" Head[%] String



Top 50 recent answers are included