Time Conversion problem - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > Other Programming - Perl, C++, Java, ASP, .NET Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-28-2011, 03:48 AM   #1 (permalink)
Regular User
 
Join Date: Jan 2011
Location: Bangladesh
Posts: 626
Question Time Conversion problem

Can anyone here who give me a code of time conversion.

For example: I put integer value say 70 minute then it shows 1:10 hrs.

It must be C++ code
__________________
BLAM Ads makes me over $7,000 a month, read my comment here!
I switched my traffic from the others and I'm making more!!!!!
mygold is offline   Reply With Quote
Sponsored Links
Old 04-29-2011, 05:48 AM   #2 (permalink)
Member
 
Join Date: Apr 2011
Posts: 136
Red face Re: Time Conversion problem

Plz Try this code:

class ofxMidiEventArgs: public ofEventArgs{
public:
int port;
int channel;
int status;
int byteOne;
int byteTwo;
double timestamp;
};

#define kMTCFrames 0
#define kMTCSeconds 1
#define kMTCMinutes 2
#define kMTCHours 3

// callback for when a midi message is received
void newMidiMessage(ofxMidiEventArgs& eventArgs){

if(eventArgs.status == 240) { // if this is a MTC message...
// these static variables could be globals, or class properties etc.
static int times[4] = {0, 0, 0, 0}; // this static buffer will hold our 4 time componens (frames, seconds, minutes, hours)
static char *szType = ""; // SMPTE type as string (24fps, 25fps, 30fps drop-frame, 30fps)
static int numFrames = 100; // number of frames per second (start off with arbitrary high number until we receive it)

int messageIndex = eventArgs.byteOne >> 4; // the high nibble: which quarter message is this (0...7).
int value = eventArgs.byteOne & 0x0F; // the low nibble: value
int timeIndex = messageIndex>>1; // which time component (frames, seconds, minutes or hours) is this
bool bNewFrame = messageIndex % 4 == 0;


// the time encoded in the MTC is 1 frame behind by the time we have received a new frame, so adjust accordingly
if(bNewFrame) {
times[kMTCFrames]++;
if(times[kMTCFrames] >= numFrames) {
times[kMTCFrames] %= numFrames;
times[kMTCSeconds]++;
if(times[kMTCSeconds] >= 60) {
times[kMTCSeconds] %= 60;
times[kMTCMinutes]++;
if(times[kMTCMinutes] >= 60) {
times[kMTCMinutes] %= 60;
times[kMTCHours]++;
}
}
}
printf("%i:%i:%i:%i | %s\n", times[3], times[2], times[1], times[0], szType);
}


if(messageIndex % 2 == 0) { // if this is lower nibble of time component
times[timeIndex] = value;
} else { // ... or higher nibble
times[timeIndex] |= value<<4;
}


if(messageIndex == 7) {
times[kMTCHours] &= 0x1F; // only use lower 5 bits for hours (higher bits indicate SMPTE type)
int smpteType = value >> 1;
switch(smpteType) {
case 0: numFrames = 24; szType = "24 fps"; break;
case 1: numFrames = 25; szType = "25 fps"; break;
case 2: numFrames = 30; szType = "30 fps (drop-frame)"; break;
case 3: numFrames = 30; szType = "30 fps"; break;
default: numFrames = 100; szType = " **** unknown SMPTE type ****";
}
}
}
}
================================================== ========
Canada Drugs
Canada Drugs
Buy Orthovisc
Company Fuel Cards
sweetsianjali is offline   Reply With Quote
Old 04-29-2011, 05:58 AM   #3 (permalink)
Member
 
Join Date: Apr 2011
Posts: 136
Default Re: Time Conversion problem

You Can Try Thia One Also



#include "stdafx.h"

#include <iostream>

#include <ctime>

#include <string>

#include <sstream>

#include <math.h>



#pragma unmanaged // generate native code


void double_to_string()

{

std::clock_t start = std::clock() ;

for(int i = 0; i < 2000000; i++)

{

double Number1 = 8.12;

static std::string Num;

static std::stringstream v1;

v1 << Number1;

v1 >> Num;

}

std::clock_t end = std::clock() ;

std::cout << "double_to_string: "

<< double( end-start ) / CLOCKS_PER_SEC << '\n' ;
}
.
#pragma managed



#pragma unmanaged // generate native code

void string_to_double()

{

std::clock_t start = std::clock() ;

for(int i = 0; i < 2000000; i++)

{

double Number1 ;

static std::string Num = "8.12" ;

static std::stringstream v1;

v1 << Num;

v1 >> Number1;

}

std::clock_t end = std::clock() ;

std::cout << "string_to_double: "

<< double( end-start ) / CLOCKS_PER_SEC << '\n' ;

}

#pragma managed



#pragma unmanaged // generate native code

void cstrng_to_double()

{

std::clock_t start = std::clock() ;
for(int i = 0; i < 2000000; i++)

{

double Number1 ;

const char* Num = "8.12";

Number1 = std::atof(Num);

}

std::clock_t end = std::clock() ;

std::cout << "cstrng_to_double: "

<< double( end-start ) / CLOCKS_PER_SEC << '\n' ;

}

#pragma managed



int main( array< System::String^ >^ args )

{

for( int i=0 ; i<4 ; ++i )

{

double_to_string() ;

string_to_double() ;

cstrng_to_double() ;

std::cout << '\n' ;

}

}

========================================


Euflexxa
Buy Plavix online
Buy Perlane
sweetsianjali is offline   Reply With Quote
Old 05-12-2011, 01:48 AM   #4 (permalink)
Junior Member
 
Join Date: Apr 2011
Posts: 57
Default Re: Time Conversion problem

Thank you ,sweetsianjali
pread is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:11 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting