Im trying to write a function that takes my decimal degrees (lat or long) and converts them to DMS degrees minutes seconds. I know I am meant to times the decimal point number by 60 then it's decimal again. But am a noob. Would I split the number?
function ConvertDDToDMS(DD) {
eg. DD =-42.4
D= 42;
M= 4*60;
S= .M * 60;
var DMS =
return DMS //append Direction (N, S, E, W);
}
Am I on the right track?
function ConvertDDToDMS(D, lng) {
return {
dir: D < 0 ? (lng ? "W" : "S") : lng ? "E" : "N",
deg: 0 | (D < 0 ? (D = -D) : D),
min: 0 | (((D += 1e-9) % 1) * 60),
sec: (0 | (((D * 60) % 1) * 6000)) / 100,
};
}
The above gives you an object {deg, min, sec, dir} with sec truncated to two digits (e.g. 3.14) and dir being one of N, E, S, W depending on whether you set the lng (longitude) parameter to true. e.g.:
ConvertDDToDMS(-18.213, true) == {
deg : 18,
min : 12,
sec : 46.79,
dir : 'W'
}
Or if you just want the basic string:
function ConvertDDToDMS(D){
return [0|D, 'd ', 0|(D=(D<0?-D:D)+1e-4)%1*60, "' ", 0|D*60%1*60, '"'].join('');
}
ConvertDDToDMS(-18.213) == `-18d 12' 47"`
[edit June 2019] -- fixing an 8 year old bug that would sometimes cause the result to be 1 minute off due to floating point math when converting an exact minute, e.g. ConvertDDToDMS(4 + 20/60).
[edit Dec 2021] -- Whoops. Fix #2. Went back to the original code and added 1e-9 to the value which a) bumps any slightly low floating point errors to the next highest number and b) is less than .01 sec, so has no effect on the output. Added 1e-4 to the "string" version which is the same fix, but also rounds seconds (it's close to 1/2 sec).
It's not clear how you need the output. Here's a version that returns all 3 values as a string:
function ConvertDDToDMS(dd)
{
var deg = dd | 0; // truncate dd to get degrees
var frac = Math.abs(dd - deg); // get fractional part
var min = (frac * 60) | 0; // multiply fraction by 60 and truncate
var sec = frac * 3600 - min * 60;
return deg + "d " + min + "' " + sec + "\"";
}
Update: I remove the part that did not make any sense (thanks cwolves!).
Here you have yet another implementation. It won't be as short nor efficient as the previous ones, but hopefully much easier to understand.
To get it right, first you need to understand how the calculations are done and only then attempt to implement them. For that, pseudocode is a great option, since you write down the steps in plain English or a simplified syntax that is easy to understand, and then translate it onto the programming language of choice.
I hope it's useful!
/* This is the pseudocode you need to follow:
* It's a modified version from
* http://en.wikipedia.org/wiki/Geographic_coordinate_conversion#Conversion_from_Decimal_Degree_to_DMS
function deg_to_dms ( degfloat )
Compute degrees, minutes and seconds:
deg ← integerpart ( degfloat )
minfloat ← 60 * ( degfloat - deg )
min ← integerpart ( minfloat )
secfloat ← 60 * ( minfloat - min )
Round seconds to desired accuracy:
secfloat ← round( secfloat, digits )
After rounding, the seconds might become 60. These two
if-tests are not necessary if no rounding is done.
if secfloat = 60
min ← min + 1
secfloat ← 0
end if
if min = 60
deg ← deg + 1
min ← 0
end if
Return output:
return ( deg, min, secfloat )
end function
*/
function deg_to_dms (deg) {
var d = Math.floor (deg);
var minfloat = (deg-d)*60;
var m = Math.floor(minfloat);
var secfloat = (minfloat-m)*60;
var s = Math.round(secfloat);
// After rounding, the seconds might become 60. These two
// if-tests are not necessary if no rounding is done.
if (s==60) {
m++;
s=0;
}
if (m==60) {
d++;
m=0;
}
return ("" + d + ":" + m + ":" + s);
}
Try this working perfect!!!
function truncate(n) {
return n > 0 ? Math.floor(n) : Math.ceil(n);
}
function getDMS(dd, longOrLat) {
let hemisphere = /^[WE]|(?:lon)/i.test(longOrLat)
? dd < 0
? "W"
: "E"
: dd < 0
? "S"
: "N";
const absDD = Math.abs(dd);
const degrees = truncate(absDD);
const minutes = truncate((absDD - degrees) * 60);
const seconds = ((absDD - degrees - minutes / 60) * Math.pow(60, 2)).toFixed(2);
let dmsArray = [degrees, minutes, seconds, hemisphere];
return `${dmsArray[0]}°${dmsArray[1]}'${dmsArray[2]}" ${dmsArray[3]}`;
}
var lat = 13.041107;
var lon = 80.233232;
var latDMS = getDMS(lat, 'lat');
var lonDMS = getDMS(lon, 'long');
console.log('latDMS: '+ latDMS);
console.log('lonDMS: '+ lonDMS);
Output:
latDMS: 13°2'27.99" N
lonDMS: 80°13'59.64" E
A solution with the option for specifying the decimal places in output seconds and correction of any edge cases due to rounding seconds and minutes.
// # input {deg} Numeric; degrees number to convert
// # input {dplaces} Decimal places to use for output seconds
// Default 0 places
// # return {DMS} string degrees (°) minutes (') seconds (")
//
function degToDMS (deg, dplaces=0) {
var d = Math.floor (deg); // make degrees
var m = Math.floor((deg-d)*60); // make minutes
var s = Math.round(((deg-d)*60-m)*60*Math.pow(10,dplaces))/Math.pow(10,dplaces); // Make sec rounded
s == 60 && (m++, s=0 ); // if seconds rounds to 60 then increment minutes, reset seconds
m == 60 && (d++, m=0 ); // if minutes rounds to 60 then increment degress, reset minutes
return (d + "° " + m + "' " + s+'"'); // create output DMS string
}
// ----- tests ------
console.log(degToDMS(55.23456)); // 55° 14' 4"
console.log(degToDMS(55.23456 ,3)); // 55° 14' 4.416"
console.log(degToDMS(4 + 20/60 ,2)); // 4° 20' 0"
console.log(degToDMS(89.64789 ,2)); // 89° 38' 52.4"
console.log(degToDMS(-23.1234567,3)); // -24° 52' 35.556"
This one works %100 in TypeScript:
ConvertDDToDMS(deg: number, lng: boolean): string {
var d = parseInt(deg.toString());
var minfloat = Math.abs((deg - d) * 60);
var m = Math.floor(minfloat);
var secfloat = (minfloat - m) * 60;
var s = Math.round((secfloat + Number.EPSILON) * 100) / 100
d = Math.abs(d);
if (s == 60) {
m++;
s = 0;
}
if (m == 60) {
d++;
m = 0;
}
let dms = {
dir: deg < 0 ? lng ? 'W' : 'S' : lng ? 'E' : 'N',
deg: d,
min: m,
sec: s
};
return `${dms.deg}\u00B0 ${dms.min}' ${dms.sec}" ${dms.dir}`
}
private static DecimalFormat DecimalFormat = new DecimalFormat(".##");
public static void main(String[] args){
double decimal_degrees = 22.4229541515;
System.out.println(getDMS(decimal_degrees));
}
public static String getDMS(double decimal_degrees) {
double degree = Math.floor(decimal_degrees);
double minutes = ((decimal_degrees - Math.floor(decimal_degrees)) * 60.0);
double seconds = (minutes - Math.floor(minutes)) * 60.0;
return ((int)degree)+":"+((int)minutes)+":"+decimalFormat.format(seconds);
}
INPUT : 22.4229541515 OUTPUT: 22:25:22.63
Based on above answer, i've written them into javascript and php style.
JS-
function convertDDToDMS(deg, lng){
var d = parseInt(deg);
var minfloat = Math.abs((deg-d) * 60);
var m = Math.floor(minfloat);
var secfloat = (minfloat-m)*60;
var s = Math.round(secfloat);
d = Math.abs(d);
if (s==60) {
m++;
s=0;
}
if (m==60) {
d++;
m=0;
}
return {
dir : deg<0?lng?'W':'S':lng?'E':'N',
deg : d,
min : m,
sec : s
};
}
PHP-
function convertDDtoDMS($deg, $lng){
$dd = intval($deg);
$minfloat = abs(($deg - $dd) * 60);
$mm = floor($minfloat);
$secfloat = ($minfloat - $mm) * 60;
$ss = round($secfloat);
$dd = abs($dd);
if($ss == 60){
$mm++;
$ss = 0;
}
if($mm == 60){
$dd++;
$mm = 0;
}
$dd = array(
'dir' => $deg < 0 ? ($lng ? 'W' : 'S') : ($lng ? 'E' : 'N'),
'deg' => abs($dd),
'min' => $mm,
'sec' => $ss,
);
return $dd;
}
couldnt get the script above working, after some time came up with this;
just give the dms to the script
function ConvertDMSToDEG(dms) {
var dms_Array = dms.split(/[^\d\w\.]+/);
var degrees = dms_Array[0];
var minutes = dms_Array[1];
var seconds = dms_Array[2];
var direction = dms_Array[3];
var deg = (Number(degrees) + Number(minutes)/60 + Number(seconds)/3600).toFixed(6);
if (direction == "S" || direction == "W") {
deg = deg * -1;
} // Don't do anything for N or E
return deg;
}
and visa versa just give the degrees to the script, and true of false for lat (latitude)
function ConvertDEGToDMS(deg, lat) {
var absolute = Math.abs(deg);
var degrees = Math.floor(absolute);
var minutesNotTruncated = (absolute - degrees) * 60;
var minutes = Math.floor(minutesNotTruncated);
var seconds = ((minutesNotTruncated - minutes) * 60).toFixed(2);
if (lat) {
var direction = deg >= 0 ? "N" : "S";
} else {
var direction = deg >= 0 ? "E" : "W";
}
return degrees + "°" + minutes + "'" + seconds + "\"" + direction;
}
hope this helps people..
I'm surprised all solutions are using some additional logic to handle the "rounds to 60" cases (if they're aware of it at all), but nobody thought of doing it the other way round, starting with (rounded) seconds and then using mod and int-div and not have to worry about all that:
function coordToStr(coord)
{
let seconds = Math.round(Math.abs(coord) * 3600)
let sec = Math.floor(seconds % 60)
let minutes = Math.floor(seconds / 60)
let min = minutes % 60
let deg = Math.floor(minutes / 60)
return deg + "°" + ((min < 10) ? "0" : "") + min + "'" + ((sec < 10) ? "0" : "") + sec
}
Sorry, this is without the N/S, E/W part, would need some additional method calling it.
If you want second-fractions, you could use this:
function coordToStrWithDecimals(coord)
{
let centiSecs = Math.round(Math.abs(coord) * 360000)
let frac = Math.floor(centiSecs % 100)
let seconds = Math.floor(centiSecs / 100)
let sec = Math.floor(seconds % 60)
let minutes = Math.floor(seconds / 60)
let min = minutes % 60
let deg = Math.floor(minutes / 60)
return deg + "°" + ((min < 10) ? "0" : "") + min + "'" + ((sec < 10) ? "0" : "") + sec + "." + ((frac < 10) ? "0" : "") + frac + '"'
}
just for remark, the answer
function ConvertDDToDMS(D){
return [0|D, 'd ', 0|(D<0?D=-D:D)%1*60, "' ", 0|D*60%1*60, '"'].join('');
}
does not work for angles between -1° and 0°.
Bad luck!
hc
Related
The method ol.coordinate.toStringHDMS() will output in a format of degress, minutes and seconds with compass direction, e.g. 47° 59′ 59″ N 7° 50′ 59″ E
But is there a way to output degrees and minutes without seconds? Truncating the seconds is not appropriate as it will ignore rounding.
e.g. the above example should round to 48° 00′ N 7° 51′ E however truncating seconds would erronesouly give 47° 59′ N 7° 50′ E
You need to make your own function derivating it from both
ol.coordinate.toStringHDMS
ol.coordinate.degreesToStringHDMS (the second one depends from the first function)
Suggested derived functions:
function toStringHDM(coordinate) {
if (coordinate) {
return (degreesToStringHDM('NS', coordinate[1]) +
' ' +
degreesToStringHDM('EW', coordinate[0]));
}
else {
return '';
}
}
and:
function degreesToStringHDM(hemispheres, degrees, opt_fractionDigits = 0) {
var normalizedDegrees = modulo(degrees + 180, 360) - 180;
var x = Math.abs(3600 * normalizedDegrees);
var dflPrecision = opt_fractionDigits || 0;
var precision = Math.pow(10, dflPrecision);
var deg = Math.floor(x / 3600);
var min = Math.floor((x - deg * 3600) / 60);
var sec = x - deg * 3600 - min * 60;
sec = Math.ceil(sec * precision) / precision;
if (sec >= 60) {
sec = 0;
min += 1;
}
if (min >= 60) {
min = 0;
deg += 1;
}
return (deg +
'\u00b0 ' +
padNumber(min, 2) +
'\u2032 ' +
(normalizedDegrees == 0
? ''
: ' ' + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0)));
}
Please note: assuming the compiler will do the job for me, I intentionally left a lot of dead code inside degreesToStringHDM() in order to keep it as close as possible to OpenLayers' original function degreesToStringHDMS(), should you need to compare both in the future (for example, when OpenLayers will be releasing a new version of this function, potentially fixing some bugs, you may be interested to perform a diff in order to quickly find what needs to be fixed here...)
In a web game I am trying to display remaining time in HH:MM:SS format -
by using the following code (the backend sends remaining epoch timestamps as game.expire1 and game.expire2 via Websockets):
var expireDiv1 = $('#expire1');
var expireDiv2 = $('#expire2');
setInterval(function() {
var now = Math.floor(new Date().getTime() / 1000);
var left1 = game.expire1 - now;
var left2 = game.expire2 - now;
if (left1 > 0) {
var hh1 = Math.floor(left1 / 60 / 60) % 60;
var mm1 = Math.floor(left1 / 60) % 60;
var ss1 = left1 % 60;
expireDiv1.html(
hh1 +
(mm1.length > 1 ? ':' : ':0') + // DELIMITER; DOES NOT WORK
mm1 +
(ss1.length > 1 ? ':' : ':0') + // DELIMITER; DOES NOT WORK
ss1);
} else {
expireDiv1.html('');
}
if (left2 > 0) {
var hh2 = Math.floor(left2 / 60 / 60) % 60;
var mm2 = Math.floor(left2 / 60) % 60;
var ss2 = left2 % 60;
expireDiv2.html(
hh2 +
(mm2.length > 1 ? ':' : ':0') + // DELIMITER; DOES NOT WORK
mm2 +
(ss2.length > 1 ? ':' : ':0') + // DELIMITER; DOES NOT WORK
ss2);
} else {
expireDiv2.html('');
}
}, 1000);
As you can see above, my naive trick is to set the delimiters between hours, minutes and seconds to ':' or ':0' depending on the string length -
(ss1.length > 1 ? ':' : ':0')
However this does not work as expected, because ss1.length returns undefined instead of 1 or 2 which I was expecting (I thought Javascript would cast my integer number of seconds to a string?)
What would you recommend here please as a most portable workaround?
The variables you're checking the .length property of are numbers, this kind of variables don't have that property.
What you could do instead of val.length > 1 is val > 9.
How about
(ss1 >= 10 ? ':' : ':0')
Also see Pad a number with leading zeros in JavaScript for more options.
Date object has method to get hour, minutes and seconds.
You can put them into an array, add 0 if necessary and call join method to concat array into string with ":" separator,
var left1 = new Date(/*game.expire1 - now*/);
var left1hours = left1.getHours();
var left1minutes = left1.getMinutes();
var left1seconds = left1.getSeconds();
var timeArray = [left1hours, left1minutes, left1seconds].map(function (l1) {
return (l1<10)? "0"+l1 : l1;
})
console.log(timeArray.join(":"))
This is a function version, same logic I just made it more compact.
function timestampToHMMSS(ts) {
return ["getHours", "getMinutes", "getSeconds"]
.map(function(s) {
return (new Date(ts))[s]();
})
.map(function (t) {
return (t<10)? "0"+t : t;
})
.join(":");
}
console.log(timestampToHMMSS(new Date()));
console.log(timestampToHMMSS(1517948038*1000));
I am having a three String or Float values say 9.30, 8.00 and 0.40 as Total_hour, Paid_hour, Extra_hour
These should be actually 9 hours 30 minutes, 8 hours 0 minutes, 0 hours 40 minutes.
Question 1) How to convert 9.30 to 9 hours 30 minutes
Question 2) Later want to Subtract and get Remaining Hour = Total_hour-Paid_Hour-Extra_hour
Later the answer Remaining Hour should be in float
This should work.
You just need to convert to ms:
let timefloat = 9.3;
function convertToMs(timefloat) {
// Get the minutes portion
let remainder = timefloat % 1;
// Convert into ms
let minutes = remainder * 100 * 60 * 1000;
// Get the number of hours and convert to ms
let hours = (timefloat - remainder) * 60 * 60 * 1000;
return minutes + hours;
}
// Convert back to float format
function convertToFloat(date) {
let hours = date.getUTCHours();
let mins = date.getUTCMinutes();
return hours + (mins / 100);
}
// Log the result
console.log(new Date(convertToMs(9.3)).toUTCString());
console.log(new Date(convertToMs(8.0)).toUTCString());
console.log(new Date(convertToMs(9.3) - convertToMs(8.0)).toUTCString());
let diff = convertToMs(9.3) - convertToMs(8.0);
console.log(convertToFloat(new Date(diff)))
The following javascript snippet converts a given float to hours and minutes. Source float to time
function convertNumToTime(number) {
// Check sign of given number
var sign = (number >= 0) ? 1 : -1;
// Set positive value of number of sign negative
number = number * sign;
// Separate the int from the decimal part
var hour = Math.floor(number);
var decpart = number - hour;
var min = 1 / 60;
// Round to nearest minute
decpart = min * Math.round(decpart / min);
var minute = Math.floor(decpart * 60) + '';
// Add padding if need
if (minute.length < 2) {
minute = '0' + minute;
}
// Add Sign in final result
sign = sign == 1 ? '' : '-';
// Concate hours and minutes
time = sign + hour + ':' + minute;
return time;
}
console.log(convertNumToTime(11.15));
Output
11:09
First convert the number in minutes and then do your subtraction. Then convert your output to hours.
var Total_hour = '9.30',
Paid_hour = '8.00',
Extra_hour = '0.40';
var conversionInMinutes = hour => Math.floor(hour) * 60 + (hour - (Math.floor(hour))) * 100;
var conversionInHours = min => Math.floor( min/60 ) + min % 60 / 100;
var Remaining_hour = conversionInMinutes(Total_hour) - conversionInMinutes(Paid_hour) - conversionInMinutes(Extra_hour);
console.log(conversionInHours(Remaining_hour).toFixed(2));
function doTime(input)
{
input = input.toString()
inputs = input.split(".")
return (inputs[0] + "Hour and" + inputs[1] + "minutes")
}
doTime("9:22")
function substract2
function subtract2(a , b){
a = input.toString()
arrayA = input.split(".")
b = input.toString()
arrayB = input.split(".")
h = parseInt(arrayB[0]) - parseInt(arrayA[0])
h <0 ? h+=12/*or 24*/ :h=h
m = parseInt(arrayB[1]) - parseInt(arrayA[1])
if(m<0){h-- ; m+=60}
return h.toString() + ":" + m.toString()
}
Hello i have a problem with this code. I have tried several ways but without a success to get zero before hours etc. Also I checked different topics but without a success.
var timestamp = (Date.now() + 1000 * 2 * 60 * 24 * 1) - Date.now();
timestamp /= 1000;
function component(x, v) {
return Math.floor(x / v);
}
/* last thing i tried but maybe it will help someone
Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = "0" + s;}
return s;
};
*/
var $div = $('div');
setInterval(function () {
timestamp--;
var
hours = component(timestamp, 60 * 60),
minutes = component(timestamp, 60) % 60,
seconds = component(timestamp, 1) % 60;
$div.html(hours + ":" + minutes + ":" + seconds);
}, 1000);
DEMO : http://jsfiddle.net/5z7ahmze/1/
Thank you for your time.
You can check your variable and add a 0 before if needed :
var comp = component(timestamp, 60 * 60);
var hour = comp < 10 ? '0' + comp : comp;
You can create a function like this
function pad(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;
}
return str;
}
and then
$div.html(pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2));
Maybe that is what you want. Right?
EDIT
Ok, the final answer.
var interval = setInterval(function () {
timestamp--;
function addZero (number) {
var zeroedNumber = (number < 10) ? 0 + "" + number : number;
return zeroedNumber;
}
var
hours = addZero(component(timestamp, 60 * 60)),
minutes = addZero(component(timestamp, 60) % 60),
seconds = addZero(component(timestamp, 1) % 60);
$div.html(hours + ":" + minutes + ":" + seconds);
//Below, i helped you with a "stop count" handler. (:
if(hours == 0 & minutes == 0 & seconds == 1){
clearInterval(interval);
}
}, 1000);
Dinamically dding zeroes to your counter if (hour or minute or second) is < 10.
I think your code is working, if you call the pad function on the numbers:
$div.html(hours.pad() + ":" + minutes.pad() + ":" + seconds.pad());
does someone know how to convert GPS degree to decimal values or vice versa?
I have to develop a way where users can insert an address and get the GPS values (both degree and/or decimal), but the main thing i need to know is how to convert the values, cause users can also insert GPS values (degree or decimal). Because i need to get the map from google maps this needs decimal.
I've tryed some codes but i get big numbers...like this one:
function ConvertDMSToDD(days, minutes, seconds, direction) {
var dd = days + minutes/60 + seconds/(60*60);
//alert(dd);
if (direction == "S" || direction == "W") {
dd = '-' + dd;
} // Don't do anything for N or E
return dd;
}
Any one?
Thank you.
First thank you #Eugen Rieck for your help.
Here is my final code, hope it can help someone:
degree to decimal
function getDMS2DD(days, minutes, seconds, direction) {
direction.toUpperCase();
var dd = days + minutes/60 + seconds/(60*60);
//alert(dd);
if (direction == "S" || direction == "W") {
dd = dd*-1;
} // Don't do anything for N or E
return dd;
}
decimal to degree based on this link
function getDD2DMS(dms, type){
var sign = 1, Abs=0;
var days, minutes, secounds, direction;
if(dms < 0) { sign = -1; }
Abs = Math.abs( Math.round(dms * 1000000.));
//Math.round is used to eliminate the small error caused by rounding in the computer:
//e.g. 0.2 is not the same as 0.20000000000284
//Error checks
if(type == "lat" && Abs > (90 * 1000000)){
//alert(" Degrees Latitude must be in the range of -90. to 90. ");
return false;
} else if(type == "lon" && Abs > (180 * 1000000)){
//alert(" Degrees Longitude must be in the range of -180 to 180. ");
return false;
}
days = Math.floor(Abs / 1000000);
minutes = Math.floor(((Abs/1000000) - days) * 60);
secounds = ( Math.floor((( ((Abs/1000000) - days) * 60) - minutes) * 100000) *60/100000 ).toFixed();
days = days * sign;
if(type == 'lat') direction = days<0 ? 'S' : 'N';
if(type == 'lon') direction = days<0 ? 'W' : 'E';
//else return value
return (days * sign) + 'º ' + minutes + "' " + secounds + "'' " + direction;
}
alert(getDD2DMS(-8.68388888888889, 'lon'));
`
couldnt get the script above working, after some time came up with this;
just give the dms to the function
function ConvertDMSToDEG(dms) {
var dms_Array = dms.split(/[^\d\w\.]+/);
var degrees = dms_Array[0];
var minutes = dms_Array[1];
var seconds = dms_Array[2];
var direction = dms_Array[3];
var deg = (Number(degrees) + Number(minutes)/60 + Number(seconds)/3600).toFixed(6);
if (direction == "S" || direction == "W") {
deg = deg * -1;
} // Don't do anything for N or E
return deg;
}
and visa versa just give the degrees to the script, and true of false for lat (latitude)
function ConvertDEGToDMS(deg, lat) {
var absolute = Math.abs(deg);
var degrees = Math.floor(absolute);
var minutesNotTruncated = (absolute - degrees) * 60;
var minutes = Math.floor(minutesNotTruncated);
var seconds = ((minutesNotTruncated - minutes) * 60).toFixed(2);
if (lat) {
var direction = deg >= 0 ? "N" : "S";
} else {
var direction = deg >= 0 ? "E" : "W";
}
return degrees + "°" + minutes + "'" + seconds + "\"" + direction;
}
hope this helps people..