Is the DateFormat read only?

classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Is the DateFormat read only?

ELS Prothero via use-livecode
A quick test seems to show that the DateFormat can’t be changed by a ‘set’ command.

How then can I force a date to be in a given format? I’m really thinking of the difference between US and European dates, i.e

d/m/y versus m/d/y

Obviously for some types of use, an LC program should be able to force the format for consistency’s sake, regardless of where in the world it’s being run.

Can it be done?

Graham
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
You can  always use a shell command for things like
Dates and Calendars etc.  Google it and you will get
plenty of info.

JB

> On Oct 28, 2020, at 2:59 PM, Graham Samuel via use-livecode <[hidden email]> wrote:
>
> A quick test seems to show that the DateFormat can’t be changed by a ‘set’ command.
>
> How then can I force a date to be in a given format? I’m really thinking of the difference between US and European dates, i.e
>
> d/m/y versus m/d/y
>
> Obviously for some types of use, an LC program should be able to force the format for consistency’s sake, regardless of where in the world it’s being run.
>
> Can it be done?
>
> Graham
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
In reply to this post by ELS Prothero via use-livecode
You can convert any given date to dateItems. Then you can use dateItems to present the date in any format you like. A date converted to dateItems will give you the following list of items:

the year
the month number
the day of the month
the hour in 24-hour time
the minute
the second
the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth
All according to the Dictionary.

To be sure that any valid date format is recognized as a date when you read in the date you will like to convert, it is best to ask for the system date or set the useSystemDate to true, as this will make all valid date formats convert to dateItems.

Best regards
Tore Nilsen

> 28. okt. 2020 kl. 22:58 skrev Graham Samuel via use-livecode <[hidden email]>:
>
> A quick test seems to show that the DateFormat can’t be changed by a ‘set’ command.
>
> How then can I force a date to be in a given format? I’m really thinking of the difference between US and European dates, i.e
>
> d/m/y versus m/d/y
>
> Obviously for some types of use, an LC program should be able to force the format for consistency’s sake, regardless of where in the world it’s being run.
>
> Can it be done?
>
> Graham
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
Thanks Tore - I had forgotten the existence of dateItems. That of course will do the trick. BTW I was trying to create dates in standard UTC format, and now I can.

Graham

> On 28 Oct 2020, at 23:18, Tore Nilsen via use-livecode <[hidden email]> wrote:
>
> You can convert any given date to dateItems. Then you can use dateItems to present the date in any format you like. A date converted to dateItems will give you the following list of items:
>
> the year
> the month number
> the day of the month
> the hour in 24-hour time
> the minute
> the second
> the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth
> All according to the Dictionary.
>
> To be sure that any valid date format is recognized as a date when you read in the date you will like to convert, it is best to ask for the system date or set the useSystemDate to true, as this will make all valid date formats convert to dateItems.
>
> Best regards
> Tore Nilsen
>> 28. okt. 2020 kl. 22:58 skrev Graham Samuel via use-livecode <[hidden email]>:
>>
>> A quick test seems to show that the DateFormat can’t be changed by a ‘set’ command.
>>
>> How then can I force a date to be in a given format? I’m really thinking of the difference between US and European dates, i.e
>>
>> d/m/y versus m/d/y
>>
>> Obviously for some types of use, an LC program should be able to force the format for consistency’s sake, regardless of where in the world it’s being run.
>>
>> Can it be done?
>>
>> Graham
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
Just FYI, I think the dictionary is wrong or misleading in respect of what the dateItems does. If you script this in the LC Message Box:

put the date into t1
convert t1 to dateItems
put t1

You get, e.g.
2020,10,29,0,0,0,5


but if you script

put the english time into t1
convert t1 to dateItems
put t1

You get e.g.
2020,10,29,11,40,0,5

i.e if you specify the date, you only get the date; but if you specify the time, you get the date thrown in. I could not deduce this from the Dictionary, but maybe I am just poor at reading what it says.

Graham

> On 29 Oct 2020, at 09:29, Graham Samuel via use-livecode <[hidden email]> wrote:
>
> Thanks Tore - I had forgotten the existence of dateItems. That of course will do the trick. BTW I was trying to create dates in standard UTC format, and now I can.
>
> Graham
>
>> On 28 Oct 2020, at 23:18, Tore Nilsen via use-livecode <[hidden email]> wrote:
>>
>> You can convert any given date to dateItems. Then you can use dateItems to present the date in any format you like. A date converted to dateItems will give you the following list of items:
>>
>> the year
>> the month number
>> the day of the month
>> the hour in 24-hour time
>> the minute
>> the second
>> the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth
>> All according to the Dictionary.
>>
>> To be sure that any valid date format is recognized as a date when you read in the date you will like to convert, it is best to ask for the system date or set the useSystemDate to true, as this will make all valid date formats convert to dateItems.
>>
>> Best regards
>> Tore Nilsen
>>> 28. okt. 2020 kl. 22:58 skrev Graham Samuel via use-livecode <[hidden email]>:
>>>
>>> A quick test seems to show that the DateFormat can’t be changed by a ‘set’ command.
>>>
>>> How then can I force a date to be in a given format? I’m really thinking of the difference between US and European dates, i.e
>>>
>>> d/m/y versus m/d/y
>>>
>>> Obviously for some types of use, an LC program should be able to force the format for consistency’s sake, regardless of where in the world it’s being run.
>>>
>>> Can it be done?
>>>
>>> Graham
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
If you only use a date and  convert it, dateItems will assume the time to be midnight on that particular date.

Tore

> 29. okt. 2020 kl. 12:04 skrev Graham Samuel via use-livecode <[hidden email]>:
>
> Just FYI, I think the dictionary is wrong or misleading in respect of what the dateItems does. If you script this in the LC Message Box:
>
> put the date into t1
> convert t1 to dateItems
> put t1
>
> You get, e.g.
> 2020,10,29,0,0,0,5
>
>
> but if you script
>
> put the english time into t1
> convert t1 to dateItems
> put t1
>
> You get e.g.
> 2020,10,29,11,40,0,5
>
> i.e if you specify the date, you only get the date; but if you specify the time, you get the date thrown in. I could not deduce this from the Dictionary, but maybe I am just poor at reading what it says.
>
> Graham
>
>> On 29 Oct 2020, at 09:29, Graham Samuel via use-livecode <[hidden email]> wrote:
>>
>> Thanks Tore - I had forgotten the existence of dateItems. That of course will do the trick. BTW I was trying to create dates in standard UTC format, and now I can.
>>
>> Graham
>>
>>> On 28 Oct 2020, at 23:18, Tore Nilsen via use-livecode <[hidden email]> wrote:
>>>
>>> You can convert any given date to dateItems. Then you can use dateItems to present the date in any format you like. A date converted to dateItems will give you the following list of items:
>>>
>>> the year
>>> the month number
>>> the day of the month
>>> the hour in 24-hour time
>>> the minute
>>> the second
>>> the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth
>>> All according to the Dictionary.
>>>
>>> To be sure that any valid date format is recognized as a date when you read in the date you will like to convert, it is best to ask for the system date or set the useSystemDate to true, as this will make all valid date formats convert to dateItems.
>>>
>>> Best regards
>>> Tore Nilsen
>>>> 28. okt. 2020 kl. 22:58 skrev Graham Samuel via use-livecode <[hidden email]>:
>>>>
>>>> A quick test seems to show that the DateFormat can’t be changed by a ‘set’ command.
>>>>
>>>> How then can I force a date to be in a given format? I’m really thinking of the difference between US and European dates, i.e
>>>>
>>>> d/m/y versus m/d/y
>>>>
>>>> Obviously for some types of use, an LC program should be able to force the format for consistency’s sake, regardless of where in the world it’s being run.
>>>>
>>>> Can it be done?
>>>>
>>>> Graham
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
I understand it, but the Dictionary is misleading and in one case actually wrong: when it says the ’time’ form gives the seconds - it doesn’t. You need to use the ‘long time’, at least so it seems to me. I have submitted a bug report.

I also thought that I could use the ToUniversalTime function, but that assumes you already know the time zone. Although LC has a Time Zone library, I haven’t found any documentation explaining how an app can find out which Time Zone it’s actually in. In fact my app doesn’t care that much, so will stick to UTC.

The documentation around all this needs a bit of tidying up, IMHO.

Graham

> On 29 Oct 2020, at 12:07, Tore Nilsen via use-livecode <[hidden email]> wrote:
>
> If you only use a date and  convert it, dateItems will assume the time to be midnight on that particular date.
>
> Tore
>
>> 29. okt. 2020 kl. 12:04 skrev Graham Samuel via use-livecode <[hidden email]>:
>>
>> Just FYI, I think the dictionary is wrong or misleading in respect of what the dateItems does. If you script this in the LC Message Box:
>>
>> put the date into t1
>> convert t1 to dateItems
>> put t1
>>
>> You get, e.g.
>> 2020,10,29,0,0,0,5
>>
>>
>> but if you script
>>
>> put the english time into t1
>> convert t1 to dateItems
>> put t1
>>
>> You get e.g.
>> 2020,10,29,11,40,0,5
>>
>> i.e if you specify the date, you only get the date; but if you specify the time, you get the date thrown in. I could not deduce this from the Dictionary, but maybe I am just poor at reading what it says.
>>
>> Graham
>>
>>> On 29 Oct 2020, at 09:29, Graham Samuel via use-livecode <[hidden email]> wrote:
>>>
>>> Thanks Tore - I had forgotten the existence of dateItems. That of course will do the trick. BTW I was trying to create dates in standard UTC format, and now I can.
>>>
>>> Graham
>>>
>>>> On 28 Oct 2020, at 23:18, Tore Nilsen via use-livecode <[hidden email]> wrote:
>>>>
>>>> You can convert any given date to dateItems. Then you can use dateItems to present the date in any format you like. A date converted to dateItems will give you the following list of items:
>>>>
>>>> the year
>>>> the month number
>>>> the day of the month
>>>> the hour in 24-hour time
>>>> the minute
>>>> the second
>>>> the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth
>>>> All according to the Dictionary.
>>>>
>>>> To be sure that any valid date format is recognized as a date when you read in the date you will like to convert, it is best to ask for the system date or set the useSystemDate to true, as this will make all valid date formats convert to dateItems.
>>>>
>>>> Best regards
>>>> Tore Nilsen
>>>>> 28. okt. 2020 kl. 22:58 skrev Graham Samuel via use-livecode <[hidden email]>:
>>>>>
>>>>> A quick test seems to show that the DateFormat can’t be changed by a ‘set’ command.
>>>>>
>>>>> How then can I force a date to be in a given format? I’m really thinking of the difference between US and European dates, i.e
>>>>>
>>>>> d/m/y versus m/d/y
>>>>>
>>>>> Obviously for some types of use, an LC program should be able to force the format for consistency’s sake, regardless of where in the world it’s being run.
>>>>>
>>>>> Can it be done?
>>>>>
>>>>> Graham
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> [hidden email]
>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
You can get the time zone, or at least the zone offset, by using "the
internet date".

--
Jacqueline Landman Gay | [hidden email]
HyperActive Software | http://www.hyperactivesw.com
On October 29, 2020 8:21:46 AM Graham Samuel via use-livecode
<[hidden email]> wrote:

> I understand it, but the Dictionary is misleading and in one case actually
> wrong: when it says the ’time’ form gives the seconds - it doesn’t. You
> need to use the ‘long time’, at least so it seems to me. I have submitted a
> bug report.
>
> I also thought that I could use the ToUniversalTime function, but that
> assumes you already know the time zone. Although LC has a Time Zone
> library, I haven’t found any documentation explaining how an app can find
> out which Time Zone it’s actually in. In fact my app doesn’t care that
> much, so will stick to UTC.
>
> The documentation around all this needs a bit of tidying up, IMHO.
>
> Graham
>
>> On 29 Oct 2020, at 12:07, Tore Nilsen via use-livecode
>> <[hidden email]> wrote:
>>
>> If you only use a date and  convert it, dateItems will assume the time to
>> be midnight on that particular date.
>>
>> Tore
>>
>>> 29. okt. 2020 kl. 12:04 skrev Graham Samuel via use-livecode
>>> <[hidden email]>:
>>>
>>> Just FYI, I think the dictionary is wrong or misleading in respect of what
>>> the dateItems does. If you script this in the LC Message Box:
>>>
>>> put the date into t1
>>> convert t1 to dateItems
>>> put t1
>>>
>>> You get, e.g.
>>> 2020,10,29,0,0,0,5
>>>
>>>
>>> but if you script
>>>
>>> put the english time into t1
>>> convert t1 to dateItems
>>> put t1
>>>
>>> You get e.g.
>>> 2020,10,29,11,40,0,5
>>>
>>> i.e if you specify the date, you only get the date; but if you specify the
>>> time, you get the date thrown in. I could not deduce this from the
>>> Dictionary, but maybe I am just poor at reading what it says.
>>>
>>> Graham
>>>
>>>> On 29 Oct 2020, at 09:29, Graham Samuel via use-livecode
>>>> <[hidden email]> wrote:
>>>>
>>>> Thanks Tore - I had forgotten the existence of dateItems. That of course
>>>> will do the trick. BTW I was trying to create dates in standard UTC format,
>>>> and now I can.
>>>>
>>>> Graham
>>>>
>>>>> On 28 Oct 2020, at 23:18, Tore Nilsen via use-livecode
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> You can convert any given date to dateItems. Then you can use dateItems to
>>>>> present the date in any format you like. A date converted to dateItems will
>>>>> give you the following list of items:
>>>>>
>>>>> the year
>>>>> the month number
>>>>> the day of the month
>>>>> the hour in 24-hour time
>>>>> the minute
>>>>> the second
>>>>> the numeric day of the week where Sunday is day 1, Monday is day 2, and so
>>>>> forth
>>>>> All according to the Dictionary.
>>>>>
>>>>> To be sure that any valid date format is recognized as a date when you read
>>>>> in the date you will like to convert, it is best to ask for the system date
>>>>> or set the useSystemDate to true, as this will make all valid date formats
>>>>> convert to dateItems.
>>>>>
>>>>> Best regards
>>>>> Tore Nilsen
>>>>>> 28. okt. 2020 kl. 22:58 skrev Graham Samuel via use-livecode
>>>>>> <[hidden email]>:
>>>>>>
>>>>>> A quick test seems to show that the DateFormat can’t be changed by a ‘set’
>>>>>> command.
>>>>>>
>>>>>> How then can I force a date to be in a given format? I’m really thinking of
>>>>>> the difference between US and European dates, i.e
>>>>>>
>>>>>> d/m/y versus m/d/y
>>>>>>
>>>>>> Obviously for some types of use, an LC program should be able to force the
>>>>>> format for consistency’s sake, regardless of where in the world it’s being run.
>>>>>>
>>>>>> Can it be done?
>>>>>>
>>>>>> Graham
>>>>>> _______________________________________________
>>>>>> use-livecode mailing list
>>>>>> [hidden email]
>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>> subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> [hidden email]
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
In reply to this post by ELS Prothero via use-livecode
I believe that when you convert a pure time to dateitems it assumes the current date. The date has no time component so it assumes midnight of the current date.

Bob S


> On Oct 29, 2020, at 04:04 , Graham Samuel via use-livecode <[hidden email]> wrote:
>
> Just FYI, I think the dictionary is wrong or misleading in respect of what the dateItems does. If you script this in the LC Message Box:
>
> put the date into t1
> convert t1 to dateItems
> put t1
>
> You get, e.g.
> 2020,10,29,0,0,0,5
>
>
> but if you script
>
> put the english time into t1
> convert t1 to dateItems
> put t1
>
> You get e.g.
> 2020,10,29,11,40,0,5
>
> i.e if you specify the date, you only get the date; but if you specify the time, you get the date thrown in. I could not deduce this from the Dictionary, but maybe I am just poor at reading what it says.
>
> Graham
>
>> On 29 Oct 2020, at 09:29, Graham Samuel via use-livecode <[hidden email]> wrote:
>>
>> Thanks Tore - I had forgotten the existence of dateItems. That of course will do the trick. BTW I was trying to create dates in standard UTC format, and now I can.
>>
>> Graham
>>
>>> On 28 Oct 2020, at 23:18, Tore Nilsen via use-livecode <[hidden email]> wrote:
>>>
>>> You can convert any given date to dateItems. Then you can use dateItems to present the date in any format you like. A date converted to dateItems will give you the following list of items:
>>>
>>> the year
>>> the month number
>>> the day of the month
>>> the hour in 24-hour time
>>> the minute
>>> the second
>>> the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth
>>> All according to the Dictionary.
>>>
>>> To be sure that any valid date format is recognized as a date when you read in the date you will like to convert, it is best to ask for the system date or set the useSystemDate to true, as this will make all valid date formats convert to dateItems.
>>>
>>> Best regards
>>> Tore Nilsen
>>>> 28. okt. 2020 kl. 22:58 skrev Graham Samuel via use-livecode <[hidden email]>:
>>>>
>>>> A quick test seems to show that the DateFormat can’t be changed by a ‘set’ command.
>>>>
>>>> How then can I force a date to be in a given format? I’m really thinking of the difference between US and European dates, i.e
>>>>
>>>> d/m/y versus m/d/y
>>>>
>>>> Obviously for some types of use, an LC program should be able to force the format for consistency’s sake, regardless of where in the world it’s being run.
>>>>
>>>> Can it be done?
>>>>
>>>> Graham
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
In reply to this post by ELS Prothero via use-livecode
Jacque

Right as usual. I had forgotten about the internet date, if I ever knew. I suppose somewhere there is a little essay about all this but if so it is buried in the LC documentation.

The only souci with this format is that it gives the month in alpha, presumably according to the nationality of the OS. But it’s easy to get the numeric month in other ways. Still, it is just a little bit fiddly to create a full UTC date of the format:

YYYY-MM-DDThh:mm:ssTZD

Works OK now, just slightly more lines of code than I would have guessed.

Thanks (again).

Graham

> On 29 Oct 2020, at 18:15, J. Landman Gay via use-livecode <[hidden email]> wrote:
>
> You can get the time zone, or at least the zone offset, by using "the internet date".
>
> --
> Jacqueline Landman Gay | [hidden email]
> HyperActive Software | http://www.hyperactivesw.com
> On October 29, 2020 8:21:46 AM Graham Samuel via use-livecode <[hidden email]> wrote:
>
>> I understand it, but the Dictionary is misleading and in one case actually wrong: when it says the ’time’ form gives the seconds - it doesn’t. You need to use the ‘long time’, at least so it seems to me. I have submitted a bug report.
>>
>> I also thought that I could use the ToUniversalTime function, but that assumes you already know the time zone. Although LC has a Time Zone library, I haven’t found any documentation explaining how an app can find out which Time Zone it’s actually in. In fact my app doesn’t care that much, so will stick to UTC.
>>
>> The documentation around all this needs a bit of tidying up, IMHO.
>>
>> Graham
>>
>>> On 29 Oct 2020, at 12:07, Tore Nilsen via use-livecode <[hidden email]> wrote:
>>>
>>> If you only use a date and  convert it, dateItems will assume the time to be midnight on that particular date.
>>>
>>> Tore
>>>
>>>> 29. okt. 2020 kl. 12:04 skrev Graham Samuel via use-livecode <[hidden email]>:
>>>>
>>>> Just FYI, I think the dictionary is wrong or misleading in respect of what the dateItems does. If you script this in the LC Message Box:
>>>>
>>>> put the date into t1
>>>> convert t1 to dateItems
>>>> put t1
>>>>
>>>> You get, e.g.
>>>> 2020,10,29,0,0,0,5
>>>>
>>>>
>>>> but if you script
>>>>
>>>> put the english time into t1
>>>> convert t1 to dateItems
>>>> put t1
>>>>
>>>> You get e.g.
>>>> 2020,10,29,11,40,0,5
>>>>
>>>> i.e if you specify the date, you only get the date; but if you specify the time, you get the date thrown in. I could not deduce this from the Dictionary, but maybe I am just poor at reading what it says.
>>>>
>>>> Graham
>>>>
>>>>> On 29 Oct 2020, at 09:29, Graham Samuel via use-livecode <[hidden email]> wrote:
>>>>>
>>>>> Thanks Tore - I had forgotten the existence of dateItems. That of course will do the trick. BTW I was trying to create dates in standard UTC format, and now I can.
>>>>>
>>>>> Graham
>>>>>
>>>>>> On 28 Oct 2020, at 23:18, Tore Nilsen via use-livecode <[hidden email]> wrote:
>>>>>>
>>>>>> You can convert any given date to dateItems. Then you can use dateItems to present the date in any format you like. A date converted to dateItems will give you the following list of items:
>>>>>>
>>>>>> the year
>>>>>> the month number
>>>>>> the day of the month
>>>>>> the hour in 24-hour time
>>>>>> the minute
>>>>>> the second
>>>>>> the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth
>>>>>> All according to the Dictionary.
>>>>>>
>>>>>> To be sure that any valid date format is recognized as a date when you read in the date you will like to convert, it is best to ask for the system date or set the useSystemDate to true, as this will make all valid date formats convert to dateItems.
>>>>>>
>>>>>> Best regards
>>>>>> Tore Nilsen
>>>>>>> 28. okt. 2020 kl. 22:58 skrev Graham Samuel via use-livecode <[hidden email]>:
>>>>>>>
>>>>>>> A quick test seems to show that the DateFormat can’t be changed by a ‘set’ command.
>>>>>>>
>>>>>>> How then can I force a date to be in a given format? I’m really thinking of the difference between US and European dates, i.e
>>>>>>>
>>>>>>> d/m/y versus m/d/y
>>>>>>>
>>>>>>> Obviously for some types of use, an LC program should be able to force the format for consistency’s sake, regardless of where in the world it’s being run.
>>>>>>>
>>>>>>> Can it be done?
>>>>>>>
>>>>>>> Graham
>>>>>>> _______________________________________________
>>>>>>> use-livecode mailing list
>>>>>>> [hidden email]
>>>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>
>>>>>> _______________________________________________
>>>>>> use-livecode mailing list
>>>>>> [hidden email]
>>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> [hidden email]
>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
I have a formatDate() function (not to be confused with dateFormat) that has a few extra formats, one I call sql date for instance which is yyyy-mm-dd (and another function for time so I can produce a datetime compatible for SQL databases).

I suppose it can be expanded for other formats, but when it comes to time zones, everything gets very complicated. Someone posted an article years ago as to why calculating current date and time in any given location is so complicated, and it has mostly to do with local standards. There are so many special cases, it really takes a centrally managed database to keep track of it all.

Bob S


> On Oct 29, 2020, at 14:33 , Graham Samuel via use-livecode <[hidden email]> wrote:
>
> Jacque
>
> Right as usual. I had forgotten about the internet date, if I ever knew. I suppose somewhere there is a little essay about all this but if so it is buried in the LC documentation.
>
> The only souci with this format is that it gives the month in alpha, presumably according to the nationality of the OS. But it’s easy to get the numeric month in other ways. Still, it is just a little bit fiddly to create a full UTC date of the format:
>
> YYYY-MM-DDThh:mm:ssTZD
>
> Works OK now, just slightly more lines of code than I would have guessed.
>
> Thanks (again).
>
> Graham

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
In reply to this post by ELS Prothero via use-livecode
On 10/29/20 4:33 PM, Graham Samuel via use-livecode wrote:
> The only souci with this format is that it gives the month in alpha, presumably according to the nationality of the OS. But it’s easy to get the numeric month in other ways. Still, it is just a little bit fiddly to create a full UTC date of the format:
>
> YYYY-MM-DDThh:mm:ssTZD

Here's something I use:

   put the seconds into tTime
   convert tTime to dateitems
   subtract (char 1 to -3 of last word of the internet date) from item 4 of tTime
   convert tTime to dateitems
   set the numberformat to "00"
   put item 1 of tTime &"-"& (item 2 of tTime)+0 &"-"& (item 3 of tTime)+0 & "T" & (item 4 of
tTime)+0 &":"& \
         (item 5 of tTime)+0 &":"& (item 6 of tTime)+0 & "Z" into tTimestamp

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
But that will only work for those time zones whose variation from UTC is
an exact number of hours.

the internet date has 4 digits so that it can handle hour and minute
variations - you could change

   subtract (char 1 to -3 of last word of the internet date) from item 4
of tTime

to

   put the last word of the internet time into tmp
   subtract (char 1 to -3 of tmp) from item 4 of tTime
   subtract (char 1 of tmp & char -2 to -1 of tmp) ) from item 5 of tTime

and then you would be handling all cases correctly.

Alex.

On 30/10/2020 20:06, J. Landman Gay via use-livecode wrote:

> On 10/29/20 4:33 PM, Graham Samuel via use-livecode wrote:
>> The only souci with this format is that it gives the month in alpha,
>> presumably according to the nationality of the OS. But it’s easy to
>> get the numeric month in other ways. Still, it is just a little bit
>> fiddly to create a full UTC date of the format:
>>
>> YYYY-MM-DDThh:mm:ssTZD
>
> Here's something I use:
>
>   put the seconds into tTime
>   convert tTime to dateitems
>   subtract (char 1 to -3 of last word of the internet date) from item
> 4 of tTime
>   convert tTime to dateitems
>   set the numberformat to "00"
>   put item 1 of tTime &"-"& (item 2 of tTime)+0 &"-"& (item 3 of
> tTime)+0 & "T" & (item 4 of tTime)+0 &":"& \
>         (item 5 of tTime)+0 &":"& (item 6 of tTime)+0 & "Z" into
> tTimestamp
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
Good point. For our situation, hours were enough so I guess I ignored the rest (it was a long
time ago and the code is old.)

On 10/30/20 3:24 PM, Alex Tweedly via use-livecode wrote:

> But that will only work for those time zones whose variation from UTC is an exact number of hours.
>
> the internet date has 4 digits so that it can handle hour and minute variations - you could change
>
>    subtract (char 1 to -3 of last word of the internet date) from item 4 of tTime
>
> to
>
>    put the last word of the internet time into tmp
>    subtract (char 1 to -3 of tmp) from item 4 of tTime
>    subtract (char 1 of tmp & char -2 to -1 of tmp) ) from item 5 of tTime
>
> and then you would be handling all cases correctly.
>
> Alex.
>
> On 30/10/2020 20:06, J. Landman Gay via use-livecode wrote:
>> On 10/29/20 4:33 PM, Graham Samuel via use-livecode wrote:
>>> The only souci with this format is that it gives the month in alpha, presumably according to
>>> the nationality of the OS. But it’s easy to get the numeric month in other ways. Still, it
>>> is just a little bit fiddly to create a full UTC date of the format:
>>>
>>> YYYY-MM-DDThh:mm:ssTZD
>>
>> Here's something I use:
>>
>>   put the seconds into tTime
>>   convert tTime to dateitems
>>   subtract (char 1 to -3 of last word of the internet date) from item 4 of tTime
>>   convert tTime to dateitems
>>   set the numberformat to "00"
>>   put item 1 of tTime &"-"& (item 2 of tTime)+0 &"-"& (item 3 of tTime)+0 & "T" & (item 4 of
>> tTime)+0 &":"& \
>>         (item 5 of tTime)+0 &":"& (item 6 of tTime)+0 & "Z" into tTimestamp
>>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
Why does:

get "Fri, 06 Nov 2020 10:57:37 +0300"
convert it to internet date
put it

— give
"Fri, 06 Nov 2020 10:57:37 +0000"

Just seems to strip the timezone info?
On 30 Oct 2020, 21:29 +0000, How to use LiveCode <[hidden email]>, wrote:
>
> ToUniversalTime
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Basic question: Time Zone Library

ELS Prothero via use-livecode
Just created a handler that I want to use in a Livecode server that uses the Time Zone Library handler TimeZones(). So:

1. How do I find where the library is?
2. How do I add it so the server code can use it?

On 6 Nov 2020, 21:28 +0000, How to use LiveCode <[hidden email]>, wrote:
>
> ToUniversalTime
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Basic question: Time Zone Library

ELS Prothero via use-livecode
Hi,

i am not sure if this is still the way how to do it with newer LC Server versions, but at least it still works with LC 9.6.1

First copy the folder of of the time zone library to your server for example into a folder extension

Then, to use the library you'll have to put the following 2 lines before your time zone specific code.

set the revLibraryMapping["tz"] to "/home/ua829968/public_html/livecode.dermattes.de/tz-test/extensions/com.livecode.library.timezone/code/x86_64-linux/tz.so"
load extension from file "./extensions/com.livecode.library.timezone/module.lcm"
//here comes your timezone script



In the first line you define where the needed shared libraries are located. It must contain the complete path to the shared libraries. In the above example the shared library for 64bit Linux is used. The second line then loads the extension.

Mark Waddingham provided that information here 2 years ago
https://www.mail-archive.com/use-livecode@.../msg97605.html

Regards,

Matthias





-
Matthias Rebbe
Life Is Too Short For Boring Code

> Am 06.11.2020 um 23:29 schrieb David Bovill via use-livecode <[hidden email]>:
>
> Just created a handler that I want to use in a Livecode server that uses the Time Zone Library handler TimeZones(). So:
>
> 1. How do I find where the library is?
> 2. How do I add it so the server code can use it?
>
> On 6 Nov 2020, 21:28 +0000, How to use LiveCode <[hidden email]>, wrote:
>>
>> ToUniversalTime
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
In reply to this post by ELS Prothero via use-livecode
I don't think it "strips" the TZ info - it simply ignores it. I think
the key phrase is in the dictionary as :

> *Note:* The *convert* command assumes all dates / times are in local
> time except for 'the seconds', which is taken to be universal time.
>
So it assume syou date is in local time (regardless of the +0300), and
therefore your example returns +0000 for you (I assume you're in the UK,
or equivalent,  now). It does the same for me, and returns the date with
"+0000".

However, the same code run on my LC server (wherever on-rev is these
days), changes the +0300 to -0500 - i.e. it's taken as local time where
the server is.


I assume you should be able to do something with the TimeZone library -
but I'm struggling to figure that out.

>    local tNow
>    put the seconds into tNow
>    put FromUniversalTime(tNow,"US/Central") into tt
>    put tNow && tt
>    put FromUniversalTime(tNow,"US/Alaska") into tt
>    put CR & tt after msg
gives me

1604709030 1604709030

1604709030

so I don't have a clue  what it was trying to do !?!

Alex.

On 06/11/2020 21:28, David Bovill via use-livecode wrote:

> Why does:
>
> get "Fri, 06 Nov 2020 10:57:37 +0300"
> convert it to internet date
> put it
>
> — give
> "Fri, 06 Nov 2020 10:57:37 +0000"
>
> Just seems to strip the timezone info?
> On 30 Oct 2020, 21:29 +0000, How to use LiveCode <[hidden email]>, wrote:
>> ToUniversalTime
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
I am as confused as anyone else as to what you are trying to do, but just in case, this little function seems to work for me to get the ’standard’ UTC date format which I have to use in my app to put time stamps into GPX files. It apparently produces the correct time zone. Doubtless it could be more elegantly coded.

Hope it helps - who knows?

Graham

function fUTCTime
   local t1,t2,t3
   -- this gets the current time and puts it into UTC format, i.e YYYY-MM-DDThh:mm:ssTZD
   put word 5 to 6 of the internet date into t3 -- we are interested in the time and time zone
   put the long time into t1
   convert t1 to dateItems -- format is yyyy,m,d,h,m,s,day no.
   put (item 1 of t1) & "-" & f2digits(item 2 of t1) & "-" & f2digits(item 3 of t1) &"T" & word 1 of t3 into t2
   put word 2 of t3 into t1 -- the time zone indication
   get char 1 of t1 — the code for 0 (zero) is Z, apparently
   if it <> "+" and it <> "-“ then
      put "Z" after t2
   else
      put t1 after t2
   end if
   return t2
end fUTCTime

function f2digits theNum
-- add a leading zero. We don't check if there are more than two digits
   if number of chars of theNum = 1 then
      return ("0" & theNum)
   else
      return theNum
   end if
end f2digits


> On 7 Nov 2020, at 01:34, Alex Tweedly via use-livecode <[hidden email]> wrote:
>
> I don't think it "strips" the TZ info - it simply ignores it. I think the key phrase is in the dictionary as :
>
>> *Note:* The *convert* command assumes all dates / times are in local time except for 'the seconds', which is taken to be universal time.
>>
> So it assume syou date is in local time (regardless of the +0300), and therefore your example returns +0000 for you (I assume you're in the UK, or equivalent,  now). It does the same for me, and returns the date with "+0000".
>
> However, the same code run on my LC server (wherever on-rev is these days), changes the +0300 to -0500 - i.e. it's taken as local time where the server is.
>
>
> I assume you should be able to do something with the TimeZone library - but I'm struggling to figure that out.
>
>>    local tNow
>>    put the seconds into tNow
>>    put FromUniversalTime(tNow,"US/Central") into tt
>>    put tNow && tt
>>    put FromUniversalTime(tNow,"US/Alaska") into tt
>>    put CR & tt after msg
> gives me
>
> 1604709030 1604709030
>
> 1604709030
>
> so I don't have a clue  what it was trying to do !?!
>
> Alex.
>
> On 06/11/2020 21:28, David Bovill via use-livecode wrote:
>> Why does:
>>
>> get "Fri, 06 Nov 2020 10:57:37 +0300"
>> convert it to internet date
>> put it
>>
>> — give
>> "Fri, 06 Nov 2020 10:57:37 +0000"
>>
>> Just seems to strip the timezone info?
>> On 30 Oct 2020, 21:29 +0000, How to use LiveCode <[hidden email]>, wrote:
>>> ToUniversalTime
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Is the DateFormat read only?

ELS Prothero via use-livecode
Thanks Graham. That does indeed work - on your local system.

The issue I am trying to deal with (and maybe it's related to what David
is doing) is dealing with time zone issues on a LC web server. If you
want to timestamp when some event happens, you can do that as a UTC
timestamp using a function like this one of yours; but that leaves you
two problems.

  - presenting those timestamps back to the user - which should be in
*their* local time
  - allowing the user to provide their own timestamp - again should be
local for them.

Most advice I've found via Google, etc. suggests keeping the timestamps
in UTC, and asking the user to provide their timezone - usually when
they 'register'. You can then use PHP (or ...) functions to convert a
date/time between UTC and their local zone.

You might hope to do that in LC using 'convert .. to internet date' -
but that doesn't work because that conversion (seems to) assume a local
time, and then simply fill in the time offset for the local system (i.e.
the problem David reported).

You should be able to do it using the TimeZone library - but I haven't
figured out how to to do that, or I'm using it wrong, or something. (I
didn't know about the Timezone library until David mentioned it yesterday.)

I'm currently using an ugly (though working :-) workaround using e.g.

put "America/New_York" into timeZone

*put*shell("TZ=" & timeZone & " date") into tmp

and working it all out from there (assumes Unix server - don't know if
it works on others).

Alex.



On 07/11/2020 10:27, Graham Samuel via use-livecode wrote:

> I am as confused as anyone else as to what you are trying to do, but just in case, this little function seems to work for me to get the ’standard’ UTC date format which I have to use in my app to put time stamps into GPX files. It apparently produces the correct time zone. Doubtless it could be more elegantly coded.
>
> Hope it helps - who knows?
>
> Graham
>
> function fUTCTime
>     local t1,t2,t3
>     -- this gets the current time and puts it into UTC format, i.e YYYY-MM-DDThh:mm:ssTZD
>     put word 5 to 6 of the internet date into t3 -- we are interested in the time and time zone
>     put the long time into t1
>     convert t1 to dateItems -- format is yyyy,m,d,h,m,s,day no.
>     put (item 1 of t1) & "-" & f2digits(item 2 of t1) & "-" & f2digits(item 3 of t1) &"T" & word 1 of t3 into t2
>     put word 2 of t3 into t1 -- the time zone indication
>     get char 1 of t1 — the code for 0 (zero) is Z, apparently
>     if it <> "+" and it <> "-“ then
>        put "Z" after t2
>     else
>        put t1 after t2
>     end if
>     return t2
> end fUTCTime
>
> function f2digits theNum
> -- add a leading zero. We don't check if there are more than two digits
>     if number of chars of theNum = 1 then
>        return ("0" & theNum)
>     else
>        return theNum
>     end if
> end f2digits
>
>
>> On 7 Nov 2020, at 01:34, Alex Tweedly via use-livecode <[hidden email]> wrote:
>>
>> I don't think it "strips" the TZ info - it simply ignores it. I think the key phrase is in the dictionary as :
>>
>>> *Note:* The *convert* command assumes all dates / times are in local time except for 'the seconds', which is taken to be universal time.
>>>
>> So it assume syou date is in local time (regardless of the +0300), and therefore your example returns +0000 for you (I assume you're in the UK, or equivalent,  now). It does the same for me, and returns the date with "+0000".
>>
>> However, the same code run on my LC server (wherever on-rev is these days), changes the +0300 to -0500 - i.e. it's taken as local time where the server is.
>>
>>
>> I assume you should be able to do something with the TimeZone library - but I'm struggling to figure that out.
>>
>>>     local tNow
>>>     put the seconds into tNow
>>>     put FromUniversalTime(tNow,"US/Central") into tt
>>>     put tNow && tt
>>>     put FromUniversalTime(tNow,"US/Alaska") into tt
>>>     put CR & tt after msg
>> gives me
>>
>> 1604709030 1604709030
>>
>> 1604709030
>>
>> so I don't have a clue  what it was trying to do !?!
>>
>> Alex.
>>
>> On 06/11/2020 21:28, David Bovill via use-livecode wrote:
>>> Why does:
>>>
>>> get "Fri, 06 Nov 2020 10:57:37 +0300"
>>> convert it to internet date
>>> put it
>>>
>>> — give
>>> "Fri, 06 Nov 2020 10:57:37 +0000"
>>>
>>> Just seems to strip the timezone info?
>>> On 30 Oct 2020, 21:29 +0000, How to use LiveCode <[hidden email]>, wrote:
>>>> ToUniversalTime
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
12