Search Results

Search found 13488 results on 540 pages for 'calculator date calculation'.

Page 4/540 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Online option calculator like Sitmo.com

    - by baraider
    I'd like to know the best way to create online calculator for stock options such as this site http://www.sitmo.com/live/OptionVanilla.html I can see it uses CGI, and I like to learn what other ways to achieve the same goals using other languages. If anyone has experience building it and can freelance, I'd like to know as well. Our site is running on LAMP.

    Read the article

  • Derivative Calculator

    - by burki
    Hi! I'm interested in building a derivative calculator. I've racked my brains over solving the problem, but I haven't found a right solution at all. May you have a hint how to start? Thanks

    Read the article

  • Question on date and timezone in Linux

    - by LinuxPenseur
    Hi , I did the date command and it gave the following output root@localhost:~$ date Thu Dec 30 14:19:47 UTC 2010 Then i modified the date using date -s command whichn gave the following output root@localhost:~$ date -s "12/30/2010 JST 14:19:47" Thu Dec 30 05:19:47 UTC 2010 I noticed that the time changed to 9 hours behind UTC time to show exactly the JST time. But timezone as you can see is still showing UTC. Why is it showing the correct time and incorrect timezone? Thanks

    Read the article

  • Algorithms or patterns for a linked question and answer cost calculator

    - by kmc
    I've been asked to build an online calculator in PHP (and the Laravel framework). It will take the answers to a series of questions to estimate the cost of a home extension. For example, a couple of questions may be: What is the lie of your property? Flat, slightly inclined, heavily inclined. (these suggestive values could have specific values in the underlying calculator like, 0 degrees, 5 degrees, 10 degrees. What is your current flooring system? Wooden, or concrete? These would then impact the results of other questions. Once the size of the extension has been input, the lie of the land will affect how much site works will cost, and how much rubbish collection will cost. The second question will impact the cost of the extensions flooring, as stumping and laying floorboards is a different cost to laying foundations and a concrete slab. It will also influence what heating and cooling systems are available in the calculator. So it's VERY interlinked. The answer to any question can influence the options of other questions, and the end result. I'm having trouble figuring out an approach to this that will allow new options and questions to be plugged in at a later stage without having things too coupled. The Observer pattern, or Laravel's events may be handy, but currently the sheer breadth of the calculator has me struggling to gather my thoughts and see a sensible implementation. Are there any patterns or OO approaches that may help? Thanks!

    Read the article

  • How do I find the Next Closest Date to today from a list of dates in a Plist on iOS?

    - by user1173823
    Situation: In short, I have a football schedule. I would like to use a custom cell which provides more info for only the next game date in the schedule. Issue: How do I find only the next closest game in the schedule (for iOS)? I've watched the WWDC 2013 video for "Solutions to Common Date and Time Issues" however this primarily applies to the Mac. I've searched numerous posts here and some are close but not what I need to find ONLY the next date from my list of dates in the schedule. From other posts I see where I can compare two specific dates, but this is not what I want to do. I want to find the next closest date that is equal to or after today from a list of dates. This is where I am now. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //Populate the table from the plist NSDictionary *season = _schedContentArray[indexPath.section]; NSArray *schedule = season[@"Schedule"]; NSDictionary *game = schedule[indexPath.row]; //find the closest game date after today's date ?? NSString *gameDateStr = game[@"GameDate"]; NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.calendar=calendar; [dateFormatter setDateFormat:@"MM/dd/yy"]; NSDate *today = [NSDate date]; NSDate *gameDate = [dateFormatter dateFromString:gameDateStr]; //NSString *nextGame = NSLog(@"game date is %@",gameDate); The NSLog returns the game dates (except for the open date): 2013-11-11 16:10:05.979 Clemson Football[24060:70b] game date is 2013-08-31 04:00:00 +0000 2013-11-11 16:10:05.982 Clemson Football[24060:70b] game date is 2013-09-07 04:00:00 +0000 2013-11-11 16:10:05.985 Clemson Football[24060:70b] game date is (null) 2013-11-11 16:10:05.987 Clemson Football[24060:70b] game date is 2013-09-19 04:00:00 +0000 2013-11-11 16:10:05.988 Clemson Football[24060:70b] game date is 2013-09-28 04:00:00 +0000 2013-11-11 16:10:05.990 Clemson Football[24060:70b] game date is 2013-10-05 04:00:00 +0000 2013-11-11 16:10:05.992 Clemson Football[24060:70b] game date is 2013-10-12 04:00:00 +0000 2013-11-11 16:10:05.993 Clemson Football[24060:70b] game date is 2013-10-19 04:00:00 +0000 2013-11-11 16:10:05.995 Clemson Football[24060:70b] game date is 2013-10-26 04:00:00 +0000 2013-11-11 16:10:05.996 Clemson Football[24060:70b] game date is 2013-11-02 04:00:00 +0000 2013-11-11 16:10:05.998 Clemson Football[24060:70b] game date is 2013-11-09 05:00:00 +0000 2013-11-11 16:10:06.000 Clemson Football[24060:70b] game date is 2013-11-14 05:00:00 +0000 2013-11-11 16:10:06.001 Clemson Football[24060:70b] game date is 2013-11-23 05:00:00 +0000 2013-11-11 16:10:06.003 Clemson Football[24060:70b] game date is 2013-11-30 05:00:00 +0000 2013-11-11 16:10:06.005 Clemson Football[24060:70b] game date is 2013-12-07 05:00:00 +0000 Thanks in advance for any assistance you can provide. This seems like it should be simple but has been fairly frustrating. Let me know if you need additional info.

    Read the article

  • Difference between LASTDATE and MAX for semi-additive measures in #DAX

    - by Marco Russo (SQLBI)
    I recently wrote an article on SQLBI about the semi-additive measures in DAX. I included the formulas common calculations and there is an interesting point that worth a longer digression: the difference between LASTDATE and MAX (which is similar to FIRSTDATE and MIN – I just describe the former, for the latter just replace the correspondent names). LASTDATE is a dax function that receives an argument that has to be a date column and returns the last date active in the current filter context. Apparently, it is the same value returned by MAX, which returns the maximum value of the argument in the current filter context. Of course, MAX can receive any numeric type (including date), whereas LASTDATE only accepts a column of type date. But overall, they seems identical in the result. However, the difference is a semantic one. In fact, this expression: LASTDATE ( 'Date'[Date] ) could be also rewritten as: FILTER ( VALUES ( 'Date'[Date] ), 'Date'[Date] = MAX ( 'Date'[Date] ) ) LASTDATE is a function that returns a table with a single column and one row, whereas MAX returns a scalar value. In DAX, any expression with one row and one column can be automatically converted into the corresponding scalar value of the single cell returned. The opposite is not true. So you can use LASTDATE in any expression where a table or a scalar is required, but MAX can be used only where a scalar expression is expected. Since LASTDATE returns a table, you can use it in any expression that expects a table as an argument, such as COUNTROWS. In fact, you can write this expression: COUNTROWS ( LASTDATE ( 'Date'[Date] ) ) which will always return 1 or BLANK (if there are no dates active in the current filter context). You cannot pass MAX as an argument of COUNTROWS. You can pass to LASTDATE a reference to a column or any table expression that returns a column. The following two syntaxes are semantically identical: LASTDATE ( 'Date'[Date] ) LASTDATE ( VALUES ( 'Date'[Date] ) ) The result is the same and the use of VALUES is not required because it is implicit in the first syntax, unless you have a row context active. In that case, be careful that using in a row context the LASTDATE function with a direct column reference will produce a context transition (the row context is transformed into a filter context) that hides the external filter context, whereas using VALUES in the argument preserve the existing filter context without applying the context transition of the row context (see the columns LastDate and Values in the following query and result). You can use any other table expressions (including a FILTER) as LASTDATE argument. For example, the following expression will always return the last date available in the Date table, regardless of the current filter context: LASTDATE ( ALL ( 'Date'[Date] ) ) The following query recap the result produced by the different syntaxes described. EVALUATE     CALCULATETABLE(         ADDCOLUMNS(              VALUES ('Date'[Date] ),             "LastDate", LASTDATE( 'Date'[Date] ),             "Values", LASTDATE( VALUES ( 'Date'[Date] ) ),             "Filter", LASTDATE( FILTER ( VALUES ( 'Date'[Date] ), 'Date'[Date] = MAX ( 'Date'[Date] ) ) ),             "All", LASTDATE( ALL ( 'Date'[Date] ) ),             "Max", MAX( 'Date'[Date] )         ),         'Date'[Calendar Year] = 2008     ) ORDER BY 'Date'[Date] The LastDate columns repeat the current date, because the context transition happens within the ADDCOLUMNS. The Values column preserve the existing filter context from being replaced by the context transition, so the result corresponds to the last day in year 2008 (which is filtered in the external CALCULATETABLE). The Filter column works like the Values one, even if we use the FILTER instead of the LASTDATE approach. The All column shows the result of LASTDATE ( ALL ( ‘Date’[Date] ) ) that ignores the filter on Calendar Year (in fact the date returned is in year 2010). Finally, the Max column shows the result of the MAX formula, which is the easiest to use and only don’t return a table if you need it (like in a filter argument of CALCULATE or CALCULATETABLE, where using LASTDATE is shorter). I know that using LASTDATE in complex expressions might create some issue. In my experience, the fact that a context transition happens automatically in presence of a row context is the main reason of confusion and unexpected results in DAX formulas using this function. For a reference of DAX formulas using MAX and LASTDATE, read my article about semi-additive measures in DAX.

    Read the article

  • Is there a calculator with LaTeX-syntax?

    - by Jørgen Fogh
    When I write math in LaTeX I often need to perform simple arithmetic on numbers in my LaTeX source, like 515.1544 + 454 = ???. I usually copy-paste the LaTeX code into Google to get the result, but I still have to manually change the syntax, e.g. \frac{154,7}{25} - (289 - \frac{1337}{42}) must be changed to 154,7/25 - (289 - 1337/42) It seems trivial to write a program to do this for the most commonly used operations. Is there a calculator which understand this syntax? EDIT: I know that doing this perfectly is impossible (because of the halting problem). Doing it for the simple cases I need is trivial. \frac, \cdot, \sqrt and a few other tags would do the trick. The program could just return an error for cases it does not understand.

    Read the article

  • Most efficient sorting of calculation on DataTable column calculation

    - by byte
    Lets say you have a DataTable that has columns of "id", "cost", "qty": DataTable dt = new DataTable(); dt.Columns.Add("id", typeof(int)); dt.Columns.Add("cost", typeof(double)); dt.Columns.Add("qty", typeof(int)); And it's keyed on "id": dt.PrimaryKey = new DataColumn[1] { dt.Columns["id"] }; Now what we are interested in is the cost per quantity. So, in other words if you had a row of: id | cost | qty ---------------- 42 | 10.00 | 2 The cost per quantity is 5.00. My question then is, given the preceeding table, assume it's constructed with many thousands of rows, and you're interested in the top 3 cost per quantity rows. The information needed is the id, cost per quantity. You cannot use LINQ. In SQL it would be trivial; how BEST (most efficiently) would you accomplish it in C# without LINQ?

    Read the article

  • What's your favorite programmable calculator?

    - by Pat Notz
    The HP-32S still holds a soft spot in my heart, even though it only had 4 registers. I have fond memories of writing a nonlinear solver for finding an azeotrope curve during a Thermodynamics final. Despite the increase in power, memory, pixels and features the HP-32G that followed never could steal my heart away. Here's to you, HP-32S. Let's hear it, what's your favorite programmable calculator? As with all poll type questions, do NOT submit a new answer unless your answer is not represented. Vote up your answer instead of adding yet another TI-85 or HP-49 to the list, and add comments to that answer if you want to relate specifics. EDIT: I moved my photo into an answer for polling.

    Read the article

  • Fractional Calculator in Java

    - by user2888881
    I am trying to create a fractional calculator in Java with inputs of mixed fractions, proper fractions, improper fractions or integers. It should include the four basic operators as well. The program should be set up as a loop where it is continuous until the user types "quit". I have coded the beginning loop but have no idea where to go from there. Please help, I am a beginner and would really appreciate it. Thank you again. This is what I have so far: import java.util.*; public class FractionCalculator { private static Scanner input; public static void main(String[] args) { input = new Scanner(System.in); String x = "quit"; System.out.println("Enter a fraction"); while (true) { String y = input.next(); if (y.equals(x)) { break; } } } }

    Read the article

  • Simple Program Question (TI-84 calculator)

    - by John
    I wrote a program (on my TI-84 calculator) to satisfy the following exercise: Write a program that will print all solutions of the inequality ax + b < c, where a, b, and c are entered by the user. In this program the domain of x will be a set of consecutive integers, where the smallest and largest members of the set will also be entered by the user. (Hint: Use a FOR . . . NEXT loop to test each integer from smallest to largest.) This is the code I have: :Input "A=",A :Input "B=",B :Input "C=",C :Disp "DOMAIN FOR X" :Input "MIN=",D :Input "MAX=",E :For(X,D,E,1) :If AX+B<C :Disp X :End I sort of figured it out by chance; I don't really know how 'If' works inside 'For.' I wanted to have it tell me if there is no solution, though, so I tried: :Input "A=",A :Input "B=",B :Input "C=",C :Disp "DOMAIN FOR X" :Input "MIN=",D :Input "MAX=",E :For(X,D,E,1) :If AX+B<C :Then :Disp X :Else :Disp "NO SOLUTION" :End But this returns the value for "MIN=" Why is this? Can anyone help me understand these work?

    Read the article

  • Hyperion Calculation Manager in the Oracle Communities

    - by THE
    (guest post by Mel)Do you use the Oracle Hyperion Calculation Manager?Did you know that an easy way to access the product knowledge of Oracle employees and other customers are the My Oracle Support Communities?Oracle Hyperion Calculation Manager can be used with these Oracle Hyperion products: HFM Hyperion Planning Hyperion Essbase OBIEE OBIA Please log into the  My Oracle Support Communities and post your question to the relevant community.I like to encourage you to add Calculation Manager or "Calc Man" at the beginning of the subject field when posting your questions.This will help the Oracle moderators and other Community member to quickly identify queries about the Oracle Hyperion Calculation Manager and assist you with it.Thank you for your ongoing contributions to our My Oracle Support Community.

    Read the article

  • Minimum and maximum Date in date Picker in iphone

    - by Iphony
    I want to get minimum and maximum date from date picker but minimum date should be "- 18" of current date and maximum date should be "- 100" of current date. Suppose current year is 2018 then I want minimum date 2000 and maximum date 1918. what I have done so far is : NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *components = [gregorian components:NSYearCalendarUnit fromDate:[NSDate date]]; NSInteger year = [components year]; int mindt = year - 18; int maxdt = year -100; // NSDate * MinDate = [components year] - 18; // NSDate * MaxDate = [components year] - 100; // self.datePicker.minimumDate = MinDate; // self.datePicker.maximumDate = MaxDate; but I cant get this integer to my date formate.. pls suggest any way ...

    Read the article

  • Display latest date from a HTML attribute

    - by Tron
    I currently have several classes which contain a date inside an attribute. <div id="container"> <div class="date" date="19/11/2013"></div> <div class="date" date="06/11/2013"></div> </div> <div id="result"></div> What I would like to do, is find the latest date and display it on the page. So far, I've found the information in the attribute, checked that it doesn't exist in the array then and pushed it into an array. I'm not entirely sure of the best approach from here, but ideally i would like to find the latest date and then append it to the results container. $('.date').each(function () { var dateArray = []; var date = $(this).attr('date'); if ($.inArray(date, dateArray) == -1) { dateArray.push(date); } $('#result').append(dateArray); }); Any assistance on the above would be greatly appreciated. Thanks :)

    Read the article

  • Most efficient way of checking if Date object and Calendar object are in the same month

    - by Indigenuity
    I am working on a project that will run many thousands of comparisons between dates to see if they are in the same month, and I am wondering what the most efficient way of doing it would be. This isn't exactly what my code looks like, but here's the gist: List<Date> dates = getABunchOfDates(); Calendar month = Calendar.getInstance(); for(int i = 0; i < numMonths; i++) { for(Date date : dates) { if(sameMonth(month, date) .. doSomething } month.add(Calendar.MONTH, -1); } Creating a new Calendar object for every date seems like a pretty hefty overhead when this comparison will happen thousands of times, soI kind of want to cheat a bit and use the deprecated method Date.getMonth() and Date.getYear() public static boolean sameMonth(Calendar month, Date date) { return month.get(Calendar.YEAR) == date.getYear() && month.get(Calendar.MONTH) == date.getMonth(); } I'm pretty close to just using this method, since it seems to be the fastest, but is there a faster way? And is this a foolish way, since the Date methods are deprecated? Note: This project will always run with Java 7

    Read the article

  • Change the Default Date setting in Word 2010

    - by Chris
    I am using Word 2010 and Windows 7. You know how when you start typing a date in Word it will automatically suggest what it thinks you want? Like if I start typing “6/29”, a little grey bubble will display “6/29/13 (Press ENTER to Insert)”. How do I get it so the bubble will display the year in a 4 digit format, such as "6/29/2013 (Press Enter to Insert)"? The below picture is how it looks when typing a date into Word. I have already gone to the Date & Time option under the Insert menu and the date format that I want is already selected. I think this is only for using quickparts anyway, so the date automatically updates when you open a document. The Region and Language settings under the Control Panel are correct as well. I thought at one point I found it somewhere under options, but I am sure I looked through everything many times and I can’t find it. I posted this exact question at the Microsoft website and someone replied: Go to the Windows Control Panel and click on Clock, Language and Region and then on Change the date, time, or number format and then modify the Short date format so that it is what you want to be used. So please don't suggest this again, because in my question I did say that I already tried this and it doesn't work, at least not for Word, in this situation. Thanks.

    Read the article

  • ASP.NET – Function to Fill Month, Date and Year into Dropdown lists

    - by SAMIR BHOGAYTA
    public void fillMonthList(DropDownList ddlList) { ddlList.Items.Add(new ListItem("Month", "Month")); ddlList.SelectedIndex = 0; DateTime month = Convert.ToDateTime("1/1/2000"); for (int intLoop = 0; intLoop { DateTime NextMont = month.AddMonths(intLoop); //ddlList.Items.Add(new ListItem(NextMont.ToString("MMMM"), NextMont.Month.ToString())); ddlList.Items.Add(new ListItem(NextMont.ToString("MMMM"), NextMont.ToString("MMMM"))); } } public void fillDayList(DropDownList ddlList) { ddlList.Items.Add(new ListItem("Day", "Day")); ddlList.SelectedIndex = 0; int totalDays = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); for (int intLoop = 1; intLoop { ddlList.Items.Add(new ListItem(intLoop.ToString(), intLoop.ToString())); } } public void fillYearList(DropDownList ddlList) { ddlList.Items.Add(new ListItem("Year", "Year")); ddlList.SelectedIndex = 0; int intYearName = 1900; for (int intLoop = intYearName; intLoop { ddlList.Items.Add(new ListItem(intLoop.ToString(), intLoop.ToString())); } }

    Read the article

  • JQuery UI Datepicker date format issue with initial value

    - by Mithun
    I need to set the initial date for the date picker to 03/20/2010 in mm-dd-yyyyy format. I have done this <input id='datepicker' type='text' value='20/03/2010' /> But my problem is on clicking the field date picker populates with today's date as highlighed and no date selected, and up on selecting date value But when i change my input field like one below <input id='datepicker' type='text' value='03/20/2010' /> Date picker is populating March 20 as selected date and current date highlighted. But all in 'mm-dd-yyyy' format! I want show all dates in 'dd-mm-yyyy' format. How can I solve this?

    Read the article

  • HQL make query searching by date (Java+NetBeans)

    - by Zloy Smiertniy
    Hi all I have the following issue. I have a table of reserves in my MySQL DB, the date columns is defined DATETIME. I need to make a query using hibernate to find all reserves in one day no matter the hour, just that its the same year month and date, and I'm doing this public List<Reserve> bringAllResByDate(Date date){ em = emf.createEntityManager(); Query q = em.createQuery("SELECT r FROM Reserve r WHERE r.date=:date "); q.setParameter("date", date); ... I really dont know how to make it compare, and bring me just those from the specified date, any help??

    Read the article

  • jQuery calculation plugin: show total in form field rather than text

    - by Katherine
    I'm embarrassed by the 'basicness' of this question, but after wasted hours, here goes. In an effort to do something with the jQuery Calculation plugin, I am playing with the basic example of the order form on the plugin site. I want to have the grand total as a form field,rather than text, so I can use the value. The function that calculates and shows the grand total is: function ($this){ // sum the total of the $("[id^=total_item]") selector var sum = $this.sum(); $("#grandTotal").text( // round the results to 2 digits sum.toFixed(2) ); } the total updates on keyup in: <span id="grandTotal"></span> But this does not work with: <input type="text" id="grandTotal" value=""/> Can anyone point me to what I need to add/change to make that work? To call my javascript basic would be a compliment, so please talk to me like I know nothing!

    Read the article

  • PHP + Code Igniter Timecode Calculation Logic Error

    - by Tim
    Hello everyone, I have what I suspect to be a logic problem with an algorithm I am using to work with Video timecode in PHP. All help is appreciated. The Objective Well basically I want to work with timecode and perform calculations For those not familiar with timecode it looks like this 01:10:58:12 or HH:MM:SS:FF 'AKA' HOURS:MINUTES:SECONDS:FRAMES I have used the script from HERE to help me with working with this format. The Problem Now can i just say that this script works!!! Timecode calculations (in this case additions) are being performed correctly. However this script continually throws the following errors, yet still produces the correct output when I try and do the following calculation 00:01:26:00 + 00:02:00:12 The errors from this calculation are shown below A PHP Error was encountered Severity: Notice Message: Undefined index: key Filename: staff/tools.php Line Number: 169 A PHP Error was encountered Severity: Notice Message: Undefined index: key Filename: staff/tools.php Line Number: 169 Line Number 169 is in the parseInput() function // feed it into the tc array $i=0; foreach ($tc AS $key=>$value) { if ( is_numeric($array["$i"]) ) { $tc["$key"]= $array["$i"]; if ($tc["$key"] < 10 && $tc["$key"] > 0 && strlen($tc['key'])==1 ) $tc["$key"]= "0".$tc["$key"]; } $i++; } return $tc; Now I should also mention that the number of times the above error is thrown depends on what I am calculating 00:00:00:00 + 00:00:00:00 returns no errors. 01:01:01:01 + 02:02:02:02 produces 8 of the above errors. For your reference, here is the code in it's entirety function add_cue_sheet_clips_process() { $sheetID = $_POST['sheet_id']; $clipName = $_POST['clip_name']; $tcIn = $_POST['tc_in']; $tcOut = $_POST['tc_out']; // string $input // returns an associative array of hours, minutes, seconds, and frames // function parseInput ($input) { // timecode should look something like hh:mm:ss;ff // allowed separators are : ; . , // values may be single or double digits // hours are least-significant -- 5.4 == 00:00:05;04 $tc= array("frames"=>"00", "seconds"=>"00", "minutes"=>"00", "hours"=>"00"); $punct= array(":", ";", ".", ","); // too big? too small? $input= trim($input); if (strlen($input)>11 || $input=="") { // invalid input, too long -- bzzt return $tc; } // normalize punctuation $input= str_replace( $punct, ":", $input); // blow it up and reverse it so frames come first $array= explode(":", $input); $array= array_reverse($array); // feed it into the tc array $i=0; foreach ($tc AS $key=>$value) { if ( is_numeric($array["$i"]) ) { $tc["$key"]= $array["$i"]; if ($tc["$key"] < 10 && $tc["$key"] > 0 && strlen($tc['key'])==1 ) $tc["$key"]= "0".$tc["$key"]; } $i++; } return $tc; } // array $tc // returns a float number of seconds // function tcToSec($tc) { $wholeseconds= ($tc['hours']*3600) + ($tc['minutes'] * 60) + ($tc['seconds']); $partseconds= ( $tc['frames'] / 25 ); $seconds= $wholeseconds + $partseconds; return $seconds; } // float $seconds // bool $subtract // returns a timecode array // function secToTc ($seconds=0, $subtract=0) { $tc= array("frames"=>"00", "seconds"=>"00", "minutes"=>"00", "hours"=>"00"); $partseconds= fmod($seconds, 1); $wholeseconds= $seconds - $partseconds; // frames if ($subtract==1) $tc['frames']= floor( $partseconds * 25 ); else $tc['frames']= floor( $partseconds * 25 ); // hours $tc['hours']= floor( $wholeseconds / 3600 ); $minsec= ($wholeseconds - ($tc['hours'] * 3600)); // minutes $tc['minutes']= floor( $minsec / 60 ); // seconds $tc['seconds']= ( $minsec - ($tc['minutes'] * 60) ); // padding foreach ( $tc AS $key=>$value ) { if ($value > 0 && $value < 10) $tc["$key"]= "0".$value; if ($value=="0") $tc["$key"]= "00"; } return $tc; } // array $tc // returns string of well-formed timecode // function tcToString (&$tc) { return $tc['hours'].":".$tc['minutes'].":".$tc['seconds'].";".$tc['frames']; } $timecodeIN = parseInput($tcIn); $timecodeOUT = parseInput($tcOut); // normalized inputs... $tc1 = tcToString($timecodeIN); $tc2 = tcToString($timecodeOUT); // get seconds $seconds1 = tcToSec($timecodeIN); $seconds2 = tcToSec($timecodeOUT); $result = $seconds1 + $seconds2; $timecode3 = secToTc($result, 0); $timecodeDUR = tcToString($timecode3); $clipArray = array('clip_name' => $clipName, 'tc_in' => $tcIn, 'tc_out' => $tcOut, 'tc_duration' => $timecodeDUR); $this->db->insert('tools_cue_sheets_clips', $clipArray); redirect('staff/tools/add_cue_sheet_clips/'.$sheetID); } I hope this is enough information for someone to help me get on top of this, I would be extremely greatful. Thanks, Tim

    Read the article

  • Given a date range how to calculate the number of weekends partially or wholly within that range?

    - by andybak
    Given a date range how to calculate the number of weekends partially or wholly within that range? (A few definitions as requested: take 'weekend' to mean Saturday and Sunday. The date range is inclusive i.e. the end date is part of the range 'wholly or partially' means that any part of the weekend falling within the date range means the whole weekend is counted.) To simplify I imagine you only actually need to know the duration and what day of the week the initial day is... I darn well now it's going to involve doing integer division by 7 and some logic to add 1 depending on the remainder but I can't quite work out what... extra points for answers in Python ;-) Edit Here's my final code. Weekends are Friday and Saturday (as we are counting nights stayed) and days are 0-indexed starting from Monday. I used onebyone's algorithm and Tom's code layout. Thanks a lot folks. def calc_weekends(start_day, duration): days_until_weekend = [5, 4, 3, 2, 1, 1, 6] adjusted_duration = duration - days_until_weekend[start_day] if adjusted_duration < 0: weekends = 0 else: weekends = (adjusted_duration/7)+1 if start_day == 5 and duration % 7 == 0: #Saturday to Saturday is an exception weekends += 1 return weekends if __name__ == "__main__": days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] for start_day in range(0,7): for duration in range(1,16): print "%s to %s (%s days): %s weekends" % (days[start_day], days[(start_day+duration) % 7], duration, calc_weekends(start_day, duration)) print

    Read the article

  • Is there a Windows or Linux equivalent of Soulver calculator application?

    - by Shevek
    I've just been shown a brilliant calculator app called Soulver which is only available on Mac OS X Maths on a Mac as it should be Soulver is a new kind of calculator application which uses a simple yet powerful word-processor style interface instead of the traditional "button" approach to doing math. Main Features No equals button - Soulver instantly calculates as you type. Multiple lines - Soulver lets you do math over multiple lines and edit previous expressions. Flexible to words - Soulver doesn't mind if you include words or labels between numbers. Basic functions - Soulver includes every standard calculator function, like sin(), cos() & tan() Clever English functions - Soulver includes some "English" math functions. For instance you can type "10% off $200" and get $180 Floating palettes - Soulver's answer & stats palettes will give you conversions and statistics on your work as your type Save your work - like a word processor, Soulver allows you to save and reopen your work This is a fantastic concept and I would really like to find it's equivalent for Windows and/or Linux. Any suggestions?

    Read the article

  • JQuery Validation [migrated]

    - by user41354
    Im trying to get my form to validate...so basically its working, but a little bit too well, I have two text boxes, one is a start date, the other an end date in the format of mm/dd/yyyy if the start date is greater than the end date...there is an error if the end date is less than the start date...there is an error if the start date is less than today's date...there is an error The only thing is when I correct the error, the error warning is still there...here is my code: dates.change(function () { var testDate = $(this).val(); var otherDate = dates.not(this).val(); var now = new Date(); now.setHours(0, 0, 0, 0); // Pass Dates if (testDate != '' && new Date(testDate) < now) { addError($(this)); $('.flightDateError').text('* Dates cannot be earlier than today.'); isValid = false; return; } // Required Text if ($(this).hasClass("FromCal") && testDate == '') { addError($(this)); $('.flightDateError').text('* Required'); isValid = false; return; } // Validate Date if (!isValidDate(testDate)) { // $(this).addClass('validation_error_input'); addError($(this)); $('.flightDateError').text('* Invalid Date'); isValid = false; return; } else { // $(this).removeClass('validation_error_input'); removeError($(this)); if (!dates.not(this).hasClass('validation_error_input')) $('.flightDateError').text(' '); } // Validate Date Ranges if ($(this).val() != '' && dates.not(this).val != '') { if ($(this).hasClass("FromCal")) { if (new Date(testDate) > new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* Start date must be earlier than end date.'); isValid = false; return; } } else{ if (new Date(testDate) < new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* End date must be later than start date.'); return; } } } }); The main Issue is this part, I believe // Validate Date Ranges if ($(this).val() != '' && dates.not(this).val != '') { if ($(this).hasClass("FromCal")) { if (new Date(testDate) > new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* Start date must be earlier than end date.'); isValid = false; return; } } else{ if (new Date(testDate) < new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* End date must be later than start date.'); return; } } } testDate is the start date otherDate is the end date Thanks in advanced, J

    Read the article

  • Check if date is allowed weekday in php?

    - by moogeek
    Hello! I'm stuck with a problem how to check if a specific date is within allowed weekdays array in php. For example, function dateIsAllowedWeekday($_date,$_allowed) { if ((isDate($_date)) && (($_allowed!="null") && ($_allowed!=null))){ $allowed_weekdays=json_decode($_allowed); $weekdays=array(); foreach($allowed_weekdays as $wd){ $weekday=date("l",date("w",strtotime($wd))); array_push($weekdays,$weekday); } if(in_array(date("l",strtotime($_date)),$weekdays)){return TRUE;} else {return FALSE;} } else {return FALSE;} } ///////////////////////////// $date="21.05.2010"; $wd="[0,1,2]"; if(dateIsAllowedWeekday($date,$wd)){echo "$date is within $wd weekday values!";} else{echo "$date isn't within $wd weekday values!"} I have input dates formatted as "d.m.Y" and an array returned from database with weekday numbers (formatted as 'Numeric representation of the day of the week') like [0,1,2] - (Sunday,Monday,Tuesday). The returned string from database can be "null", so i check it too. Them, the isDate function checks whether date is a date and it is ok. I want to check if my date, for example 21.05.2010 is an allowed weekday in this array. My function always returns TRUE and somehow weekday is always 'Thursday' and i don't know why... Is there any other ways to check this or what can be my error in the code above? thx

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >