Questions tagged [period]

A period of time is an interval, a span of time. You can also use it for questions related to the actual punctuation mark.

508 questions
11
votes
6 answers

How to compare two java.time.Period in java 8?

How do I compare two Periods in java 8? E.g. Period one = Period.of(10,0,0); Period two = Period.of(8,0,0); here in this case one is greater than two.
yetanothercoder
  • 385
  • 2
  • 6
  • 15
11
votes
2 answers

Check if a pandas.Timestamp is in a pandas.Period

# pseudo code: myPeriod.contains(myTimestamp) I found the lack of such function in pandas quite surprising. Am I missing something here?
YunliuStorage
  • 479
  • 5
  • 14
11
votes
3 answers

Any way to convert a JodaTime Period to a decimal number of hours?

I have a JodaTime Period that I've created from two DateTime instants. Is there a good way to convert that Period into a decimal number of hours? For instance, I have a Period that goes from 1pm to 1:30pm on Jan 1, 2010. How can I get that Period…
jbarz
  • 582
  • 6
  • 17
10
votes
1 answer

Count number of days that time periods overlap

Using the lubridate library, I can find out if two time periods overlapped. But, is there an efficient way to compute for how many days they overlapped. (for instance how many days a women smoked while pregnant. The pregnancy period and smoking…
9
votes
1 answer

Why does java.time.Period#normalized() not normalize days?

In the Java class java.time.Period the method normalized() has the following in its Javadoc: This normalizes the years and months units, leaving the days unit unchanged. The superclass' method has the following in its Javadoc: The process of…
D. Kovács
  • 1,232
  • 13
  • 25
9
votes
3 answers

Parsing the ISO-8601 duration values of the AMAZON.DURATION slot type

Does the java.time library provide a consolidated way to parse the entire ISO-8601 Duration Specification? The Alexa Slot Type reference for duration lists some example strings to expect when using the AMAZON.DURATION slot type. All strings are in…
Upio
  • 1,364
  • 1
  • 12
  • 27
9
votes
6 answers

How can I detect if a float has a repeating decimal expansion in C#?

I simply need to know how I can detect repeating decimal expansion in floats. Example: 0.123456789123456789 The repeating portion of the number would be 123456789. I want to automatize this in C#, is there any smart solution?
Abi
  • 159
  • 1
  • 2
  • 6
8
votes
3 answers

Adding Period to startDate doesn't produce endDate

I have two LocalDates declared as following: val startDate = LocalDate.of(2019, 10, 31) // 2019-10-31 val endDate = LocalDate.of(2019, 9, 30) // 2019-09-30 Then I calculate the period between them using Period.between function: val period =…
Ilya
  • 21,871
  • 8
  • 73
  • 92
8
votes
3 answers

Get a Period of Days between two Dates

I use java.time.Period#getDays() to get the number of days for a given period of LocalDates. It seems to work for most cases, but for a whole month, I get a period of zero days. The following test case fails (java.lang.AssertionError: expected:<30>…
kerner1000
  • 3,382
  • 1
  • 37
  • 57
8
votes
2 answers

Accessing a pandas.DataFrame column name with a '.' in it

I have a pandas dataframe df. One of the columns is Project.Fwd_Primer. I would like to access that column, however when I use df.Project.Fwd_Primer I get: AttributeError. Is there another way I can access this column, or do I need to get rid…
Patrickc01
  • 145
  • 1
  • 1
  • 6
8
votes
3 answers

Twig date loop each day in a period

So, here's my situation, I have a beginning date and an ending date, with Twig I want to be able to loop through all days in the so called period so that I could print out every day. Of course, that's just for understanding how to do it, the goal is…
soenguy
  • 1,332
  • 3
  • 11
  • 23
7
votes
4 answers

PHP Find date nearest to a timeline period

So, uh, ok. This might get mathematical, so hope you brought your scientific calculator with you ;) This is my problem: Given an initial date (timestamp), time period period (seconds) and today's date (timestamp), I need to find the nearest date…
Christian
  • 27,509
  • 17
  • 111
  • 155
7
votes
2 answers

How can I get the start and end time of a period?

I have an enum TimeFrame that has values like: Yesterday, LastWeek, NextMonth etc. I'm trying to write a method that takes in a TimeFrame and returns the start and end dates of that period of time. I looked into the new Java 8 Period class which can…
Mike Medina
  • 97
  • 1
  • 6
7
votes
2 answers

Excel: Change "," to "."

Ever since i added a multiple language option for my computer, Excel decided to turn all my decimals into commas. I need to turn them back into decimals again. How do i do this with least amount of work? If you know an EASY way to do this, emphasis…
user136128
  • 219
  • 1
  • 5
  • 12
6
votes
2 answers

Add n months to a pandas Period object?

This seems like it should be easy but I can find no answer when googling. Say I have some variable k that is of type pandas.Period, and whose value is: Period('2018-11', 'M') How do I add n months to this variable. For example if n is 3 i would…
sometimesiwritecode
  • 2,993
  • 7
  • 31
  • 69
1
2
3
33 34