mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 17:25:35 +03:00
feat(web): use timeline in geolocation manager (#21492)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { buildDateRangeFromYearMonthAndDay, getAlbumDateRange, timeToSeconds } from './date-time';
|
||||
import { getAlbumDateRange, timeToSeconds } from './date-time';
|
||||
|
||||
describe('converting time to seconds', () => {
|
||||
it('parses hh:mm:ss correctly', () => {
|
||||
@@ -75,24 +75,3 @@ describe('getAlbumDate', () => {
|
||||
expect(getAlbumDateRange({ startDate: '2021-01-01T00:00:00+05:00' })).toEqual('Jan 1, 2021');
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildDateRangeFromYearMonthAndDay', () => {
|
||||
it('should build correct date range for a specific day', () => {
|
||||
const result = buildDateRangeFromYearMonthAndDay(2023, 1, 8);
|
||||
|
||||
expect(result.from).toContain('2023-01-08T00:00:00');
|
||||
expect(result.to).toContain('2023-01-09T00:00:00');
|
||||
});
|
||||
|
||||
it('should build correct date range for a month', () => {
|
||||
const result = buildDateRangeFromYearMonthAndDay(2023, 2);
|
||||
expect(result.from).toContain('2023-02-01T00:00:00');
|
||||
expect(result.to).toContain('2023-03-01T00:00:00');
|
||||
});
|
||||
|
||||
it('should build correct date range for a year', () => {
|
||||
const result = buildDateRangeFromYearMonthAndDay(2023);
|
||||
expect(result.from).toContain('2023-01-01T00:00:00');
|
||||
expect(result.to).toContain('2024-01-01T00:00:00');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -85,33 +85,3 @@ export const getAlbumDateRange = (album: { startDate?: string; endDate?: string
|
||||
*/
|
||||
export const asLocalTimeISO = (date: DateTime<true>) =>
|
||||
(date.setZone('utc', { keepLocalTime: true }) as DateTime<true>).toISO();
|
||||
|
||||
/**
|
||||
* Creates a date range for filtering assets based on year, month, and day parameters
|
||||
*/
|
||||
export const buildDateRangeFromYearMonthAndDay = (year: number, month?: number, day?: number) => {
|
||||
const baseDate = DateTime.fromObject({
|
||||
year,
|
||||
month: month || 1,
|
||||
day: day || 1,
|
||||
});
|
||||
|
||||
let from: DateTime;
|
||||
let to: DateTime;
|
||||
|
||||
if (day) {
|
||||
from = baseDate.startOf('day');
|
||||
to = baseDate.plus({ days: 1 }).startOf('day');
|
||||
} else if (month) {
|
||||
from = baseDate.startOf('month');
|
||||
to = baseDate.plus({ months: 1 }).startOf('month');
|
||||
} else {
|
||||
from = baseDate.startOf('year');
|
||||
to = baseDate.plus({ years: 1 }).startOf('year');
|
||||
}
|
||||
|
||||
return {
|
||||
from: from.toISO() || undefined,
|
||||
to: to.toISO() || undefined,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -190,6 +190,8 @@ export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset):
|
||||
city: city || null,
|
||||
country: country || null,
|
||||
people,
|
||||
latitude: assetResponse.exifInfo?.latitude || null,
|
||||
longitude: assetResponse.exifInfo?.longitude || null,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user