Page 1 of 2

Convert date from "internet" to "New York, USA" - Solved

Posted: Thu Jan 05, 2017 5:51 pm
by DR White
How do I change "Mon, 23 Jan 2017 21:45:00 -0500" to "1/17/2017 11:45 AM" (Eastern Standard) ?

I have tried everything, even read several topics in the dictionary, without any success.

After six hours of trying, I cannot solve this problem.

Any help would be appreciated,

David

Re: Convert date from "internet" to "Eastern Standard"

Posted: Thu Jan 05, 2017 6:06 pm
by Klaus
Hi David,

no idea what "Eastern standard" is, but I doubt that the difference to internet date is really 6 (SIX) days! :D


Best

Klaus

Re: Convert date from "internet" to "Eastern Standard"

Posted: Thu Jan 05, 2017 6:11 pm
by SparkOut
Time conversion can be tricky, best start is to look up "set the useSystemDate to true" and the "convert" command.

Re: Convert date from "internet" to "Eastern Standard"

Posted: Thu Jan 05, 2017 6:24 pm
by DR White
Eastern standard is actually the same as New York, USA .

I just need the format to be 1/17/2017 11:45 AM form internet format.

Thanks,

David

Re: Convert date from "internet" to "New York, USA"

Posted: Thu Jan 05, 2017 8:10 pm
by Klaus
Hi David,

maybe something like this will do:

Code: Select all

...
put "Mon, 23 Jan 2017 21:45:00 -0500" into tDate
put tDate into tTime
convert tDate from internet date to short system date
convert tTime to system time
put tDate && tTime
...
But no chance this will EVER result in january 17th! :D


Best

Klaus

Re: Convert date from "internet" to "New York, USA"

Posted: Thu Jan 05, 2017 8:16 pm
by DR White
Klaus,

I am not where I can try the code today, I will tomorrow.

What does the "&&" do?

Thanks,

David

Re: Convert date from "internet" to "New York, USA"

Posted: Thu Jan 05, 2017 8:23 pm
by Klaus

Code: Select all

answer "Ask" && "the" && "dictionary" & "!"
:D

Re: Convert date from "internet" to "New York, USA"

Posted: Thu Jan 05, 2017 8:59 pm
by dunbarx
Hi.

This is just a matter of parsing your input date and time, whatever format that might be in, and rebuilding it by hand. You may want to play with the "internet date", the system date, the long date and long time, those sorts of things. You will see the various parts of these functions, and then it is just a matter of extracting the pertinent components and re-assembling. It is fun if you don't have to do it too often.

What did you use instead of "&&"? The space constant? Or perhaps " " ?

In any case, do get used to "&&". Very compact, and oftentimes you will find, especially in the above exercise, that the use of "&" and "&&" usually go together when building strings, which is exactly what you will be doing.

Craig Newman

Re: Convert date from "internet" to "New York, USA"

Posted: Fri Jan 06, 2017 3:27 am
by DR White
dunbarx,

Thanks for that explanation.

Klause,

Your date conversion code works good,

Thanks,

David

Re: Convert date from "internet" to "New York, USA" - Solved

Posted: Fri Jan 06, 2017 5:31 pm
by jacque
Or even shorter:

Code: Select all

get the internet date 
convert it to short date and time

Re: Convert date from "internet" to "New York, USA" - Solved

Posted: Fri Jan 06, 2017 5:36 pm
by Klaus
jacque wrote:Or even shorter:

Code: Select all

get the internet date 
convert it to short date and time
Yep! :D

I had something like this in mind, but used the && operator (... to date && time) which threw an error.
So AND is the magic word for convert here, thanks for the reminder!

Re: Convert date from "internet" to "New York, USA" - Solved

Posted: Fri Jan 06, 2017 6:15 pm
by jacque
Alas, Klaus, your HyperCard history has left you. :D

Re: Convert date from "internet" to "New York, USA" - Solved

Posted: Fri Jan 06, 2017 6:43 pm
by Klaus
jacque wrote:Alas, Klaus, your HyperCard history has left you. :D
Well, to be honest, I don't have one! :shock:

Re: Convert date from "internet" to "New York, USA" - Solved

Posted: Fri Jan 06, 2017 9:02 pm
by dunbarx
Jacque.

True. I have never seen Klaus reference HC. I believe he has heard of it, but that is all.

Craig

Re: Convert date from "internet" to "New York, USA" - Solved

Posted: Fri Jan 06, 2017 11:32 pm
by jacque
I could have sworn I'd known him since the HC list...that's how ubiquitous he is. :)