mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:52:43 +00:00 
			
		
		
		
	 cab1015a03
			
		
	
	
		cab1015a03
		
	
	
	
	
		
			
			Evidently, going one day forward on the last day of month increases the month number by one and resets the day to 1. Doing the same on the last day of the year resets the month to 1.
		
			
				
	
	
		
			37 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| describe("correct behavior", () => {
 | |
|     test("length is 1", () => {
 | |
|         expect(Temporal.Now.plainDate).toHaveLength(1);
 | |
|     });
 | |
| 
 | |
|     test("basic functionality", () => {
 | |
|         const calendar = new Temporal.Calendar("iso8601");
 | |
|         const plainDate = Temporal.Now.plainDate(calendar);
 | |
|         expect(plainDate).toBeInstanceOf(Temporal.PlainDate);
 | |
|         expect(plainDate.calendar).toBe(calendar);
 | |
|     });
 | |
| 
 | |
|     test("custom time zone", () => {
 | |
|         const calendar = new Temporal.Calendar("iso8601");
 | |
|         const timeZone = {
 | |
|             getOffsetNanosecondsFor() {
 | |
|                 return 86400000000000;
 | |
|             },
 | |
|         };
 | |
|         const plainDate = Temporal.Now.plainDate(calendar);
 | |
|         const plainDateWithOffset = Temporal.Now.plainDate(calendar, timeZone);
 | |
|         if (plainDate.dayOfYear === plainDate.daysInYear) {
 | |
|             expect(plainDateWithOffset.year).toBe(plainDate.year + 1);
 | |
|             expect(plainDateWithOffset.month).toBe(1);
 | |
|             expect(plainDateWithOffset.day).toBe(1);
 | |
|         } else {
 | |
|             expect(plainDateWithOffset.year).toBe(plainDate.year);
 | |
|             if (plainDate.day === plainDate.daysInMonth) {
 | |
|                 expect(plainDateWithOffset.month).toBe(plainDate.month + 1);
 | |
|                 expect(plainDateWithOffset.day).toBe(1);
 | |
|             } else {
 | |
|                 expect(plainDateWithOffset.month).toBe(plainDate.month);
 | |
|                 expect(plainDateWithOffset.day).toBe(plainDate.day + 1);
 | |
|             }
 | |
|         }
 | |
|     });
 | |
| });
 |