AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [INC] Time Parser (https://forums.alliedmods.net/showthread.php?t=327760)

ratawar 10-07-2020 23:10

[INC] Time Parser
 
I created this include having in mind situations where more friendly time inputs could come handier than specifying everything in minutes when we're talking about, let's say, ban times.
Instead of the user thinking how many minutes a day, a week, 2 hours or 3 months could be, this parser would solve this issue in a very elegant and practical way.

It takes inputs in the form of 3d (3 days), 4w2h (4 weeks and 2 hours), or even 1y1y120d and will sum up to the proper 2 years and 120 days.

The function sums up all valid time inputs from the string, calculates the future date it sums up to and returns that date as a UNIX timestamp.

If any questions, criticism or feedback (which is always appreciated) let me know down below. Thanks!


Include and Test Plugin Sources on GitHub!


All times are GMT -4. The time now is 18:54.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.