zig icon indicating copy to clipboard operation
zig copied to clipboard

std.time missing minute constants.

Open jfalcon opened this issue 1 year ago • 3 comments

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

  • Install Zig 0.13.0 (or master branch).
  • Go to the source for std.time example.
  • Look at line 117.

You'll notice there are no division for minutes.

Expected Behavior

Would expect to see a block for minutes and possibly hours.

// Divisions of a minute.
pub const min_per_hour = 60;
pub const min_per_day = min_per_hour * 24;
pub const min_per_week = min_per_day * 7;

jfalcon avatar Oct 13 '24 21:10 jfalcon

I suppose the argument for or against this could be that 24 is an approximation of hours in a day since the number changes on a microscopic level annually due to the universe expending, but other constants do that and it's universally accepted that 24 works.

jfalcon avatar Oct 13 '24 21:10 jfalcon

The most reasonable counter-argument for this is that nothing in std.time accepts a number in minutes. The existing constants, ns, us, ms, and sec are all numeric constants that are actually useful to pass into functions defined in std.time

truemedian avatar Oct 13 '24 23:10 truemedian

min_per_day and min_per_week are both very context and calendar specific min_per_hour is needed rare enough, along with what truemedian said, i dont think is a strong argument for it to be in std

nektro avatar Oct 14 '24 01:10 nektro