* Restoring Settings to New OS Build

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Restoring Settings to New OS Build

Post by tatewise » 31 Mar 2022 12:32

I've looked at that and it sounds promising but there are almost no example scripts and so I have no idea what Lua commands would be needed to implement that DATE conversion feature.
What luacom.CreateObject("...") statement is required? What are the conversion methods/functions available?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
ColeValleyGirl
Megastar
Posts: 4854
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Restoring Settings to New OS Build

Post by ColeValleyGirl » 31 Mar 2022 12:56

Once you've required luacom, it becomes a table. So use

Code: Select all

luacom.DateFormat = "table"
and

Code: Select all

luacom.DateFormat = "string"
The table option returns something like:

Code: Select all

		modified => (table .8)
			Hour => 16
			Second => 10
			DayOfWeek => 0
			Month => 12
			Minute => 59
			Milliseconds => 0
			Year => 2021
			Day => 12

User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Restoring Settings to New OS Build

Post by tatewise » 31 Mar 2022 14:49

Ah! The penny has dropped :roll:

This is the default that I was struggling with:

Code: Select all

luacom.DateFormat = "string"		-- this is the default
fileObj = fhFileUtils.fso:GetFile(strFilePath)
strMod = fileObj.DateLastModified	-- returns such as "30/3/2022 10:22:14 PM" depending on locale
This converts to a fixed format table regardless of the locale settings:

Code: Select all

luacom.DateFormat = "table"
fileObj = fhFileUtils.fso:GetFile(strFilePath)
dicMod = fileObj.DateLastModified	-- returns standard format table
intTime = os.time({ year=dicMod.Year; month=dicMod.Month; day=dicMod.Day; hour=dicMod.Hour; min=dicMod.Minute; sec=dicMod.Second; })
Then intTime is the UNIX epoch seconds since 01/01/1970 :D

Thank you Helen.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Restoring Settings to New OS Build

Post by tatewise » 31 Mar 2022 15:37

The attached Backup and Restore Family Historian Settings plugin Version 3.3.3 Date 31 Mar 22 uses that new technique that should cope with all local date-time formats without altering the Windows Registry.

It has the side benefit of showing date-times in messages using the current user's local format settings.
Last edited by tatewise on 01 Apr 2022 10:30, edited 1 time in total.
Reason: Attachment deleted as later version is in the Plugin Store.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
NickWalker
Megastar
Posts: 2401
Joined: 02 Jan 2004 17:39
Family Historian: V7
Location: Lancashire, UK
Contact:

Re: Restoring Settings to New OS Build

Post by NickWalker » 31 Mar 2022 15:40

I like it when a plan comes together. You and Helen make a great team :)
Nick Walker
Ancestral Sources Developer

https://fhug.org.uk/kb/kb-article/ancestral-sources/

User avatar
ColeValleyGirl
Megastar
Posts: 4854
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Restoring Settings to New OS Build

Post by ColeValleyGirl » 31 Mar 2022 16:19

Thanks, Nick.

avatar
ColinMc
Superstar
Posts: 442
Joined: 17 Jan 2019 11:35
Family Historian: V7
Location: Edinburgh

Re: Restoring Settings to New OS Build

Post by ColinMc » 31 Mar 2022 16:24

I've run a Backup with the old & new version, and it seems to be identical apart from system files, and apart from the map cache, it also matches the Windows version
Backup&Restore.jpg
Backup&Restore.jpg (197.01 KiB) Viewed 908 times
Colin McDonald - Researching McDonald, McGillivray, Tait, Rountree families

User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Restoring Settings to New OS Build

Post by tatewise » 01 Apr 2022 10:29

Backup and Restore Family Historian Settings plugin Version 3.4 Date 31 Mar 22 is now in the Plugin Store :D

I think there needs to be a KB Snippet for the code that solved this problem with related code that provides substitute values for the LuaFileSystem Attributes such as mode, access, modification, change, size, etc. I'll add it to my list :roll:
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply