NeuroAssassin / Toxic-Cogs

A collection of utility, moderation and fun plugins to Red - Discord Bot.
MIT License
47 stars 38 forks source link

[Reacticket] - zero-padded {year}{month}{day}{hour}{minute} - bug? #67

Open CruxCraft opened 2 years ago

CruxCraft commented 2 years ago

{year}{month}{day}{hour}{minute} produced: 2021112165

I don't know if that is saying it is Nov 2nd at 1:65 (65?) OR if it is saying it is more likely saying Nov 2nd at 16:05 (more likely)

I could try adding separators just to see what it was intending to say, but all of those scenarios have flaws regardless

If you get the time, could you make it so that months, days, hours, & minutes have the preceding zero? So that January 7th @ 8:05am would be 2022 01 07 0805

datetime.today().strftime('%Y-%m-%d-%H:%M:%S') '2022-01-07-08:05:59'

Could even add those seconds in if you wanted, if it's not too much trouble =]

EDIT:

        channel_name = (
            guild_settings["presetname"]["presets"][guild_settings["presetname"]["chosen"]]
            .replace("{user}", user.display_name)
            .replace("{userid}", str(user.id))
            .replace("{julian}", now.strftime("%j"))
            .replace("{year}", now.strftime("%Y"))
            .replace("{year_short}", now.strftime("%y"))
            .replace("{month}", now.strftime("%m"))
            .replace("{month_name}", now.strftime("%B"))
            .replace("{month_abr}", now.strftime("%b"))
            .replace("{day}", now.strftime("%d"))
            .replace("{day_name}", now.strftime("%A"))
            .replace("{day_abr}", now.strftime("%a"))
            .replace("{hour}", now.strftime("%H"))
            .replace("{minute}", now.strftime("%M"))
            .replace("{second}", now.strftime("%S"))
            .replace("{tzone}", now.strftime("%Z"))
            .replace("{random}", str(random.randint(1, 100000)))
        )[:100]

I looked at the source, & I think that would fix it... also added the julian date, abbreviated months & days, and short year

EDIT2: fixed my errors I edited my local file and tested... works great!!

EDIT3: I fumbled my way through my first pull request on Github. I think I tripled the number of steps it should have taken ¯_(ツ)_/¯