Changes
1 changed files (+12/-23)
-
-
@@ -8,6 +8,7 @@ type DescMessage,type MessageShape, type MessageInitShape, } from "@bufbuild/protobuf"; import { DateSchema } from "@yamori/proto/yamori/type/v1/date_pb.js"; export function isSameBytes(a: Uint8Array, b: Uint8Array): boolean { if (a.byteLength !== b.byteLength) {
-
@@ -49,31 +50,19 @@return masked; } /** * ECMAScript の Date とごっちゃにならないように名前を変えている。 */ export interface CalendarDate { /** * 1~ */ year: number; /** * 1~12 */ month: number; /** * 1~31 */ day: number; } export function packDate({ year, month, day }: CalendarDate): number { return (year << 9) | (Math.min(month, 12) << 5) | (Math.min(day, 31) & 0b11111); export function packDate({ year, month, day, }: MessageInitShape<typeof DateSchema>): number { return ( ((year ?? 0) << 9) | (Math.min(month ?? 0, 12) << 5) | (Math.min(day ?? 1, 31) & 0b11111) ); } export function unpackDate(date: number): CalendarDate { export function unpackDate(date: number): MessageInitShape<typeof DateSchema> { return { year: date >> 9, month: (date >> 5) & 0b1111,
-