LiteMount

LiteMount

2M Downloads

Feature request: Advanced rules for calendar dates

brunswick79 opened this issue ยท 8 comments

commented

I was thinking of writing a little mount addon for myself when I can across your addon which has most of the features that I want. The key feature that I am not seeing is being able to set up rules based on day of the year or a range between start and end date. Let me know if I missed it.
My personal end goal is to have pools of mounts to draw from based on the seasons. The idea came from the Wandering Ancient and how it changed it's color based on the season. Addon users could assign mount groupings based on seasons, holidays, their birthday, important anniversaries, etc.

commented

There's nothing currently in LiteMount like that. I like the idea, but i have to say it sounds very difficult. Calendaring systems and especially recurring date specification is a super difficult problem, even before the calculations, timezones, daylight savings, hemispheres/seasons, translated time/day/month/year names, etc. I have done some of this in my day job years gone by: I didn't like it!

I applaud your bravery in considering it, and I'd be very keen to see what you come up with. I don't think it's something I have time to independently make for LiteMount but I'd certainly steal anything you do and put it in if it fitted. :)

As a shower thought, I wonder if the in-game WoW calendar is good enough that you could put all the events into there and just make an API call to see if you're currently in one. I don't think it has recurring events though, at least not ones you can put in yourself.

Back on LiteMount, it's fairly fundamentally based around a macro-condition type action list line. Kind of like

SmartMount [condition] mount_args

and there's not a complicated parser for conditions, it's basically name:arg/arg/arg/arg. There's no comparison operators etc.

So there would need to be one or more condition types for the date/time-ranges. And they'd have to be possible for a human to write, read and debug (and obviously for LiteMount to parse but that's not difficult).

WoW has a date printing function equivalent to strftime: https://wowpedia.fandom.com/wiki/API_date but no rich storage of dates.

There's also the https://wowpedia.fandom.com/wiki/Category:API_namespaces/C_Calendar API but it doesn't seem very useful. Some of the functions return a CalendarTime struct but I don't think there's any API for manipulating them client-side.

I'm not aware of anyone having written a LibDateTime-1.0. You could probably port the LuaDate library into wow, it is MIT licensed.

WoW seems to have translated global tables for CALENDAR_WEEKDAY_NAMES and CALENDAR_FULLDATE_MONTH_NAMES, and also MONTH_JANUARY etc. Sadly anything useful in the Calendar UI is local and not exported.

A lot of rambling and brain dump, apologies. Summary is it's way too much work for me but it sounds cool and I'm keen to see where you get to with it.

commented

Don't even get me started on Americans and their whack m/d/y date format!

commented

LiteMount code would probably be something like:

CONDITIONS["date"] = {
    args = true,
    handler =
        function (cond, context, fromDateStr, toDateStr)        
            local fromDate = ParseDate(fromDateStr)
            if toDateStr then
                local toDate = ParseDate(toDateStr)
                return DateBetween(NowDate(), fromDate, toDate)
            else
                return DateEqual(NowDate(), fromDate)
            end
        end
}

Where ParseDate, NowDate, DateBetween and DateEqual (or some equivalent, could be OO although lua has no operator overloading) would need to be made. Not clear now the equality should work, it should probably assume any nil/unspecified fields (particularly m/h/s) don't need to match. DateBetween obviously needs to deal with the fact the toDate could be earlier in the year then the fromDate (though it's the next year).

Simplest case for just days (which would allow season) is that the date spec is "D-Mon" e.g., "1-Jan".

I have literally no idea how a spec for "Every second Tuesday" would look, let alone "every day from 11pm to 1am".

commented

Sounds like you would be comfortable with me creating a fork and putting in the functionality that I would like for myself which is just a seasonal look up condition. I don't have time for that right now but will add it as my next personal project. After I get it to where I am using it in game, we can talk about improving the usability to where you are happy with a pull request.

commented

This would be a total hack, but it might be possible to get the current season (as far as wow is concerned, if you are in the northern hemisphere) from the current model of the Wandering Ancient.

The journal knows which one to show, it's just a matter of whether that is done by having 4 models or changing the one model behind the scenes.

It would be interesting to compare the returns from
/dump C_MountJournal.GetMountInfoExtraByID(1458)
in different seasons.

https://wowpedia.fandom.com/wiki/API_C_MountJournal.GetMountInfoExtraByID

For reference in case I come back next season, this is what they are now (I'm not sure if this is summer or autumn/fall):

image

commented

Absolutely, that would be fantastic! Don't hesitate to reach out if you have any questions.

commented

Interestingly the model ID does seem to change with the seasons. May 23:

Dump: value={ C_MountJournal.GetMountInfoExtraByID(1458) }
[1]={
  [1]=100463,
  [2]="A staunch defender of the forests of Azeroth, the ancients are also known for their glorious canopies of leaves, which change color with the seasons.",
  [3]="|cFFFFD200Promotion|r",
  [4]=false,
  [5]=230,
  [6]=45,
  [7]=91,
  [8]=0,
  [9]=false
}
commented

Newest release 10.1.0-4 has support for [season] based on the wow season from the model ID of the Wandering Ancient. I think that's about all I'm keen to add as far as dates are concerned, going to close this off. Appreciate your submission and commentary!