Converter

I've built an algorithm to convert seconds into ... other things.


Story

Convert any value in seconds into a relevant unit of time, from nanoseconds to millenia.

Avoid over-precision ie show 1.5 hours, not 1.504 hours. Prefer "Just over 1.5 hours"

Use plurals i.e. 5 seconds, not 5 second


Example output

1 second is 1 second

0.009 seconds is 9 microseconds

3601 seconds is just over 1 hour


Sources for Time Units


Configuration for Time Units

					
	units: [
		{name:"nanosecond",		pluralName:"nanosecondss",		size:1e-9,		dp:"any"}, 
		{name:"millisecond",	pluralName:"milliseconds",		size:1e-6,		dp:"3"}, 
		{name:"microsecond",	pluralName:"microseconds",		size:1e-3,		dp:"3"}, 
		{name:"second",				pluralName:"seconds",		size:1,		dp:"1"}, 
		{name:"minute",				pluralName:"minutes",		size:60,		dp:"1"}, 
		{name:"hour",					pluralName:"hours",		size:3600,		dp:"2"}, 
		{name:"day",					pluralName:"days",		size:86400,		dp:"1"}, 
		{name:"week",					pluralName:"weeks",		size:604800,		dp:"0"},
		{name:"month",				pluralName:"months",		size:2629800,		dp:"0"},
		{name:"year",					pluralName:"years",		size:31557600,		dp:"0"},
		{name:"decade",				pluralName:"decade",		size:315576000,		dp:"0"},
		{name:"century",			pluralName:"centuries",		size:3155760000,		dp:"0"},
		{name:"milennium",		pluralName:"milennia",		size:31557600000,		dp:"0"}
	]
					
				

Fixes

Algorithm: better handling of negative and zero values

Testing: Added two tests to verify changes

Testing: Bulk data generation avoids numeric problems (i.e. step of 0.001 no longer occasionally produces x.xx0000000000000001)

Testing: Deeper info on metric units: sources and configuration used

Known Issues


Tests


Your Activity

Approval Tests

Property Tests