PDA

View Full Version : Calendar Database Usage Question



JimSocks
June 13th, 2021, 23:24
So currently I am using



local nday = DB.getValue("calendar.current.day");
local nMonths = DB.getValue("calendar.current.month");
local nYears = DB.getValue("calendar.current.year");


to get a numerical representation of the current date in the calendar loaded in FG.

But... how can I get the strings representing what the name of the month or day might be actually called? For instance, month #2 in the currently loaded calendar might be called "JimSockstober"... how can I reach into the DB and get that string if the date is currently set within that month?

I have boosted up the code for date calls within story templates per a forum member's requests, but I want to go a step further and implement full support for fantasy calendars instead of just gregorian, and to do so I need to know how to crack this nut!

JimSocks
June 14th, 2021, 00:02
EDIT: I think I found it. I'll post here if I am correct!

JimSocks
June 14th, 2021, 00:39
Ok yep I cracked it.
For anyone later searching for this same information, see below:



local nDays = DB.getValue("calendar.current.day");
local nMonths = DB.getValue("calendar.current.month");
local nYears = DB.getValue("calendar.current.year");
local nEpoch = DB.getValue("calendar.current.epoch");

local monthName = CalendarManager.getMonthName(nMonths);
local nWeekDay = CalendarManager.getLunarDay(nYears, nMonths, nDays);
local sWeekDay = CalendarManager.getLunarDayName(nWeekDay);
local sSuffix = Interface.getString("message_calendardaysuffix" .. (nDays % 10));

local dayWithSuffix = tostring(nDays) .. (sSuffix or "");
local dayName = sWeekDay
local fullmonth = monthName