duration

Groovy: Get duration in years

这一生的挚爱 提交于 2019-12-19 21:19:39
问题 On running the following code in groovy - import groovy.time.* import org.codehaus.groovy.runtime.TimeCategory def today = new Date() use(TimeCategory) { def modifiedToday = today.plus(10.minutes) modifiedToday = modifiedToday.plus(10.months) modifiedToday = modifiedToday.plus(10.years) def duration = modifiedToday - today println duration.years println duration.months println duration.days println duration.minutes } I am getting the following output - 0 0 3956 10 Please suggest, why am I

android get duration from maps.google.com directions

回眸只為那壹抹淺笑 提交于 2019-12-17 20:34:17
问题 At the moment I am using this code to inquire google maps for directions from an address to another one, then I simply draw it on a mapview from its GeometryCollection. But yet this isn't enough I need also to extract the total expected duration from the kml. can someone give a little sample code to help me? thanks StringBuilder urlString = new StringBuilder(); urlString.append("http://maps.google.com/maps?f=d&hl=en"); urlString.append("&saddr=");//from urlString.append( Double.toString(

YouTube Player API: How to get duration of a loaded/cued video without playing it?

若如初见. 提交于 2019-12-17 17:46:07
问题 I'm not able to get the correct video duration/length (in seconds) of a loaded/cued video via the getDuration() method of the YouTube Player API; the same method, however, returns a valid value once the video starts playing! Wondering how YouTube is able to show the valid duration of a loaded/cued video. When I load this HTML page with a 15 second video clip, I get the following debug output: state = 5 duration = -0.000025 When I hit the Play button, I get the following debug output: state =

time.Since() with months and years

℡╲_俬逩灬. 提交于 2019-12-17 15:55:10
问题 I am trying to convert a timestamp like this: 2015-06-27T09:34:22+00:00 to a time since format so it would say like 9 months ago 1 day 2 hours 30 minutes 2 seconds. something like that. I used time.Parse and time.Since to get to this: 6915h7m47.6901559s But how do I convert from there on? Something like this is what I thought: for hours > 24 { days++ hours -= 24 } But the issue with this is that this won't be accurate for months because months can have 28, 30 and 31 days. Is there a better

Android : how can I add 5 Times in a variable and get total seconds of them

百般思念 提交于 2019-12-14 04:14:39
问题 like i have 5 Times 1. 05:12:02 2. 19:12:52 3. 40:12:14 4. 56:54:10 5. 41:12:12 ----------- Total Seconds : 0#####..` ----------- i want like this, how can i , please help me . can I use this? : public String addTime(int hour, int minute, int minutesToAdd) { Calendar calendar = new GregorianCalendar(1990, 1, 1, hour, minute); calendar.add(Calendar.MINUTE, minutesToAdd); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); String date = sdf.format(calendar.getTime()); return date; } 回答1: A

Parsing an xs:duration datatype into a Python datetime.timedelta object?

耗尽温柔 提交于 2019-12-13 16:18:05
问题 As per the title, I'm trying to parse an XML file containing an xs:duration data type. I'd like to convert that into a Python timedelta object, which I can then use in further calculations. Is there any built-in way of doing this, similar to the strptime() function? If not, what is the best way to achieve this? 回答1: Seeing as I already have a working example of what I asked in the question, I'll post it here for completeness. If any better answers come up I'll accept. period = '-P14D' regex =

Output Ruby duration in iso8601

跟風遠走 提交于 2019-12-13 15:24:47
问题 I'm looking to output duration in iso8601 format in ruby on rails for schema.org. I already know how to output the timestamp in iso8601. e.g. video.created_at.iso8601 What I'm looking to do now is output something in the format of: <meta itemprop="duration" content="PT1M33S" /> That's the iso8601 duration format. You can read about the spec at http://en.wikipedia.org/wiki/ISO_8601#Durations Currently I'm hacking in a strftime, but that's not ideal... Time.at(@video.duration).strftime('PT%MM:

Get Video-Duration with avconv via Python

送分小仙女□ 提交于 2019-12-13 04:39:11
问题 I need to get the duration of an Video for an application for Django. So I'll have to do this in python. But I'm really a beginner in this. So it would be nice, if you can help. This is what I got so far: import subprocess task = subprocess.Popen("avconv -i video.mp4 2>&1 | grep Duration | cut -d ' ' -f 4 | sed -r 's/([^\.]*)\..*/\1/'", shell=True, stdout=subprocess.PIPE) time = task.communicate()[0] print time I want to solve it with avconv because I'm allready using this at another point.

Convert x hour(s) y min(s) into z minutes using Java

社会主义新天地 提交于 2019-12-13 03:42:56
问题 I have fetched google maps ETAs (that is, durations) for some routes in the format of x hour(s) y min(s) , and also if x > 24 then this format changes into u day(s) v hour(s) . Now I want to compare these values to some other ETAs so all I need to do is convert these format value into a minutes-only value. Such as I have a value as 4 hours 34 mins, I want to change it into minutes using Java or such as 1 hour 1 min to minutes, there are records where hour indicated as 1 hour and 3 hours and

R: convert text duration (“..d ..h ..m ..s”) into seconds

房东的猫 提交于 2019-12-13 02:31:35
问题 Trying to convert the following durations into seconds x <- "1005d 16h 09m 57s" x1 <- "16h 09m 57s" x2 <- "06h 09m 57s" x3 <- "09m 57s" x4 <- "57s" I've modified the answer from Jthorpe in this post Convert factor of format Hh Mm Ss to time duration. days <- as.numeric(gsub('^*([0-9]+)d.*$','\\1',x3)) hours <- as.numeric(gsub('^.*([0-9][0-9])h.*$','\\1',x3)) minutes <- as.numeric(gsub('^.*([0-9][0-9])m.*$','\\1',x4)) seconds <- as.numeric(gsub('^.*([0-9][0-9])s.*$','\\1',x4)) duration_seconds