Convert seconds back to date form
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Convert seconds back to date form
If I recorded the seconds one day into a fld, then wanted to check what day I recorded it a month later, can I use that value to convert back to the original date form when it was recorded?
-
- Livecode Opensource Backer
- Posts: 9389
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Convert seconds back to date form
I have a feeling that would be extremely awkward as months have variable lengths, and there are about 15 different calendars current in the world (For the sake of argument, LiveCode has no encoding for the Shakabda clandar (expired)), and even some of those calendars are determined not in seconds, but is subdivisions of muhurtas.
Rabbit hole this way: https://en.wikipedia.org/wiki/Hindu_calendar
HOWEVER, if you want to be fairly pedestrian and use the Gregorian calendar (!), you COULD work things out be working backwards from today's date and time.
- -
Taking into account that LiveCode (which is made in Scotland) by default uses the North American date format, which for some reason known only to the colonists, puts the day number AFTER the month number.
You would then have to do all sorts of complex calculations: first by calculating what the date & time by the Gregorian calendar is in terms of second, subtracting the seconds from your reading, and then reversing the calculation to end up with the date and time you wanted.
Rabbit hole this way: https://en.wikipedia.org/wiki/Hindu_calendar
HOWEVER, if you want to be fairly pedestrian and use the Gregorian calendar (!), you COULD work things out be working backwards from today's date and time.
- -
Taking into account that LiveCode (which is made in Scotland) by default uses the North American date format, which for some reason known only to the colonists, puts the day number AFTER the month number.
You would then have to do all sorts of complex calculations: first by calculating what the date & time by the Gregorian calendar is in terms of second, subtracting the seconds from your reading, and then reversing the calculation to end up with the date and time you wanted.
Re: Convert seconds back to date form
Yes!
Code: Select all
...
put fld "the stored seconds" into tSecs
convert tSecs to ***
## *** Select one of these options:
## date
## system date
## long date
## long system date
answer tSecs
...
Best
Klaus
-
- Livecode Opensource Backer
- Posts: 9389
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Convert seconds back to date form
Yes, of course, Klaus.
But the OP did not say which calendar he was intending to use.
The current Hebrew year, AM 5784, began at sunset on 15 September 2023 Gregorian current and will end at sunset on 2 October 2024 Gregorian current.
But the OP did not say which calendar he was intending to use.
The current Hebrew year, AM 5784, began at sunset on 15 September 2023 Gregorian current and will end at sunset on 2 October 2024 Gregorian current.
Re: Convert seconds back to date form
Yes, and that made me naively think that he, like me, just does not consider this stuff, Captain Cumbersome!richmond62 wrote: ↑Wed Jan 10, 2024 1:19 pmBut the OP did not say which calendar he was intending to use.
-
- Livecode Opensource Backer
- Posts: 9389
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Convert seconds back to date form
Round these parts (Bulgaria), the local church being bloody-minded, while being Orthodox uses the Gregorian (Catholic) calendar to calculate most Christian festivals (such as Christmas), but uses the Julian calendar to calculate Easter; which, as a person who runs a private school and has to work out the 'academic' calendar evey year, is a serious pain-in-the bum: especially as some of my pupils are Catholic (so celebrate Easter using the Gregorian calendar), or Jewish (who don't celebrate Easter, but do celebrate their own special day,s, or Muslims (who use the Islamic calendar which is 354/5 days long (so, the 2 Eids ( that's "Bairam" round these parts) precess through the Gregorian/secular year).
So, when a parent come in and says, "Why don't you have 3 days off for Kotch Bairam (Eid al-Adha)?" instead of saying, "Personally I feel that slitting a sheep's throat in the middle of the road a bit 'off'." I have to do alsorts of 'funny' calculations to readjust my school calendar, and not rub either the Christians or the Jews up the wrong way.
And as oldummy has not stated his/her country of residence and/or origin, it is both unwise and distinctly ethnocentric to assume which calendar they might be using.
HOWEVER, as all the calendars in use worldwide are just a matter of Mathematics, conversion both between calendars and between seconds (or whatever) and days, and so on, are perfectly doable in LiveCode.
So, when a parent come in and says, "Why don't you have 3 days off for Kotch Bairam (Eid al-Adha)?" instead of saying, "Personally I feel that slitting a sheep's throat in the middle of the road a bit 'off'." I have to do alsorts of 'funny' calculations to readjust my school calendar, and not rub either the Christians or the Jews up the wrong way.
And as oldummy has not stated his/her country of residence and/or origin, it is both unwise and distinctly ethnocentric to assume which calendar they might be using.
HOWEVER, as all the calendars in use worldwide are just a matter of Mathematics, conversion both between calendars and between seconds (or whatever) and days, and so on, are perfectly doable in LiveCode.
Re: Convert seconds back to date form
Yeah, got it!
If there is a bulgarian version of an operating system, what would LCs "put the SYSTEM date" then possibly return?
If there is a bulgarian version of an operating system, what would LCs "put the SYSTEM date" then possibly return?
Re: Convert seconds back to date form
Funnily enough I needed this a few days ago and use this function:
Code: Select all
function dateTimeFromSeconds pSeconds
-- return system date in item 1, system time in item 2
local tDate, tTime
convert pSeconds from seconds to dateItems
put pSeconds into tDate
put pSeconds into tTime
convert tDate from dateitems to system date
convert tTime from dateitems to system time
return tDate & comma & tTime
end dateTimeFromSeconds
HTH
Stam
Re: Convert seconds back to date form
Ahh. Thank you all for the replies. I'm still not sure if I want to store these dates using the seconds but now I can. Thanks to all again.
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Convert seconds back to date form
Seconds or InternetTime are the two formats especially useful if you need to support teams in different time zones, as they are based off of GMT and can be converted to local time easily.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn