Skip to content

Commit

Permalink
remove calendar package & integrate it directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Vijeinath committed Jan 18, 2024
1 parent 4e8bc13 commit 9d89092
Show file tree
Hide file tree
Showing 27 changed files with 2,357 additions and 12,919 deletions.
13,136 changes: 230 additions & 12,906 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
"angular-split": "^15.0.0",
"ckeditor5-custom-build": "github:dasch-swiss/ckeditor_custom_build",
"core-js": "^3.6.5",
"jdnconvertiblecalendar": "^0.0.7",
"jdnconvertiblecalendardateadapter": "^1.0.1",
"ngx-color-picker": "^13.0.0",
"openseadragon": "^2.4.2",
"rxjs": "~6.5.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Inject, Input, OnDestroy, OnInit } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { Constants } from '@dasch-swiss/dsp-js';
import { JDNConvertibleCalendar } from 'jdnconvertiblecalendar';
import { JDNConvertibleCalendar} from '../../../../../../../jdnconvertiblecalendar';
import { CalendarHeaderComponent } from '../../../../../../viewer/values/date-value/calendar-header/calendar-header.component';
import { PropertyValue, Value, ValueLiteral } from '../operator';

Expand Down
2 changes: 1 addition & 1 deletion src/app/dsp-ui-lib/viewer/services/value.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
IslamicCalendarDate,
JDNConvertibleCalendar,
JulianCalendarDate
} from 'jdnconvertiblecalendar';
} from '../../../jdnconvertiblecalendar';

@Injectable({
providedIn: 'root'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/** Custom header component containing a calendar format switcher */
import { JDNConvertibleCalendarDateAdapter } from 'jdnconvertiblecalendardateadapter';
import { JDNConvertibleCalendarDateAdapter} from '../../../../../jdnconvertiblecalendardateadapter';
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { JDNConvertibleCalendar } from 'jdnconvertiblecalendar';
import { JDNConvertibleCalendar } from '../../../../../jdnconvertiblecalendar';
import { MatCalendar, MatDatepickerContent } from '@angular/material/datepicker';
import { DateAdapter } from '@angular/material/core';
import { Component, Host, Inject, OnDestroy, OnInit } from '@angular/core';
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
Validators
} from '@angular/forms';
import { MatFormFieldControl } from '@angular/material/form-field';
import { JDNConvertibleCalendar } from 'jdnconvertiblecalendar';
import { JDNConvertibleCalendar } from '../../../../../jdnconvertiblecalendar';
import { Subject, Subscription } from 'rxjs';
import { FocusMonitor } from '@angular/cdk/a11y';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
GregorianCalendarDate,
JDNConvertibleCalendar,
JulianCalendarDate
} from 'jdnconvertiblecalendar';
} from '../../../../../jdnconvertiblecalendar';
import { Subject } from 'rxjs';
import { CalendarHeaderComponent } from '../calendar-header/calendar-header.component';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Directive, Inject, Input, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
import { JDNConvertibleCalendar } from 'jdnconvertiblecalendar';
import { ACTIVE_CALENDAR, JDNConvertibleCalendarDateAdapter } from 'jdnconvertiblecalendardateadapter';
import { JDNConvertibleCalendar} from '../../../../jdnconvertiblecalendar';
import { ACTIVE_CALENDAR, JDNConvertibleCalendarDateAdapter} from '../../../../jdnconvertiblecalendardateadapter';
import { BehaviorSubject } from 'rxjs';

export function makeCalendarToken() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import {
} from '@angular/forms';
import { CanUpdateErrorState, ErrorStateMatcher, mixinErrorState } from '@angular/material/core';
import { MatFormFieldControl } from '@angular/material/form-field';
import { CalendarDate, CalendarPeriod, GregorianCalendarDate } from 'jdnconvertiblecalendar';
import {
CalendarDate,
CalendarPeriod,
GregorianCalendarDate
} from '../../../../../jdnconvertiblecalendar';
import { Subject } from 'rxjs';
import { CustomRegex } from '../../custom-regex';

Expand Down
2 changes: 1 addition & 1 deletion src/app/dsp-ui-lib/viewer/viewer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { CKEditorModule } from '@ckeditor/ckeditor5-angular';
import { AngularSplitModule } from 'angular-split';
import { MatJDNConvertibleCalendarDateAdapterModule } from 'jdnconvertiblecalendardateadapter';
import { MatJDNConvertibleCalendarDateAdapterModule} from '../../jdnconvertiblecalendardateadapter';
import { ColorPickerModule } from 'ngx-color-picker';
import { DspActionModule } from '../action/action.module';
import { DragDropDirective } from './directives/drag-drop.directive';
Expand Down
16 changes: 16 additions & 0 deletions src/app/jdnconvertiblecalendar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright © 2021 - 2023 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/

export { CalendarDate } from './lib/CalendarDate';
export { CalendarPeriod } from './lib/CalendarPeriod';
export { JDNPeriod } from './lib/JDNPeriod';
export {
JDNConvertibleCalendar,
GregorianCalendarDate,
IslamicCalendarDate,
JulianCalendarDate,
} from './lib/JDNConvertibleCalendar';
export { JDNConvertibleConversionModule } from './lib/JDNCalendarConversion';
export { JDNConvertibleCalendarNames } from './lib/JDNCalendarNames';
43 changes: 43 additions & 0 deletions src/app/jdnconvertiblecalendar/lib/CalendarDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright © 2021 - 2023 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/

import { JDNConvertibleCalendarError } from './JDNConvertibleCalendarError';
import { Utils } from './Utils';

/**
* Represents a calendar date (calendar agnostic).
*
* Assumes that every supported calendar
* can be represented by a combination of year, month, and day.
*
*/
export class CalendarDate {
/**
*
* Please note that this software uses the (astronomical) convention that BCE dates are represented as negative years and that the year zero (0) is used.
* The year 1 BCE must be indicated as year 0, and the year 2 BCE corresponds to -1 etc.
*
* @param year year of the given date.
* @param month month of the given date.
* @param day day of the given date (day of month, 1 based index).
* @param dayOfWeek day of week of the given date (0 based index), if any.
* @param daytime time of the day (0 - 0.9…), if any. 0 refers to midnight, 0.5 to noon, 0.9… to midnight of the same day. 1 would already refer to the next day and is thus not valid.
*/
constructor(
public readonly year: number,
public readonly month: number,
public readonly day: number,
public readonly dayOfWeek?: number,
public readonly daytime?: number
) {
// check validity of daytime
if (daytime !== undefined && daytime >= 1)
throw new JDNConvertibleCalendarError(`Invalid daytime: ${daytime}, valid range: 0 - 0.9…`);

// TODO: When other calendar than Gregorian or Julian are implemented, this may have to be changed
if (dayOfWeek !== undefined && (!Utils.isInteger(dayOfWeek) || dayOfWeek < 0 || dayOfWeek > 6))
throw new JDNConvertibleCalendarError(`Invalid day of week: ${dayOfWeek}`);
}
}
23 changes: 23 additions & 0 deletions src/app/jdnconvertiblecalendar/lib/CalendarPeriod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright © 2021 - 2023 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/

/**
* Represents a period as two calendar dates.
*/
import { CalendarDate } from './CalendarDate';

export class CalendarPeriod {
/**
*
* @param periodStart start of the period.
* @param periodEnd End of the period.
*/
constructor(
public readonly periodStart: CalendarDate,
public readonly periodEnd: CalendarDate
) {
// TODO: can we check that periodStart equals or is before periodEnd?
}
}
Loading

0 comments on commit 9d89092

Please sign in to comment.