mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 05:33:00 +00:00 
			
		
		
		
	Fix time formatting (#527)
Fixes #525. Co-authored-by: R93950X <R93950X@users.noreply.github.com>
This commit is contained in:
		| @@ -77,7 +77,7 @@ function formatTime(nTime, bTwentyFourHour) | |||||||
|     local nHour = math.floor(nTime) |     local nHour = math.floor(nTime) | ||||||
|     local nMinute = math.floor((nTime - nHour) * 60) |     local nMinute = math.floor((nTime - nHour) * 60) | ||||||
|     if sTOD then |     if sTOD then | ||||||
|         return string.format("%d:%02d %s", nHour, nMinute, sTOD) |         return string.format("%d:%02d %s", nHour == 0 and 12 or nHour, nMinute, sTOD) | ||||||
|     else |     else | ||||||
|         return string.format("%d:%02d", nHour, nMinute) |         return string.format("%d:%02d", nHour, nMinute) | ||||||
|     end |     end | ||||||
|   | |||||||
| @@ -12,6 +12,14 @@ describe("The textutils library", function() | |||||||
|             expect.error(textutils.formatTime, nil):eq("bad argument #1 (expected number, got nil)") |             expect.error(textutils.formatTime, nil):eq("bad argument #1 (expected number, got nil)") | ||||||
|             expect.error(textutils.formatTime, 1, 1):eq("bad argument #2 (expected boolean, got number)") |             expect.error(textutils.formatTime, 1, 1):eq("bad argument #2 (expected boolean, got number)") | ||||||
|         end) |         end) | ||||||
|  |  | ||||||
|  |         it("correctly formats 12 o'clock", function() | ||||||
|  |             expect(textutils.formatTime(0, false)):eq("12:00 AM") | ||||||
|  |             expect(textutils.formatTime(0.1, false)):eq("12:06 AM") | ||||||
|  |  | ||||||
|  |             expect(textutils.formatTime(0, true)):eq("0:00") | ||||||
|  |             expect(textutils.formatTime(0.1, true)):eq("0:06") | ||||||
|  |         end) | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|     describe("textutils.pagedPrint", function() |     describe("textutils.pagedPrint", function() | ||||||
| @@ -49,7 +57,7 @@ describe("The textutils library", function() | |||||||
|     describe("textutils.empty_json_array", function() |     describe("textutils.empty_json_array", function() | ||||||
|         it("is immutable", function() |         it("is immutable", function() | ||||||
|             expect.error(function() textutils.empty_json_array[1] = true end) |             expect.error(function() textutils.empty_json_array[1] = true end) | ||||||
|                 :str_match("^[^:]+:51: attempt to mutate textutils.empty_json_array$") |                 :str_match("^[^:]+:%d+: attempt to mutate textutils.empty_json_array$") | ||||||
|         end) |         end) | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 R93950X
					R93950X