Skip to content

Do not crash UI for "unknown" calendar models #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/values/TimeValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@ SELF.newFromJSON = function( json ) {

// NOTE: Having the calendar model as url to Wikidata was a specified data model requirement.

// Time instance should be defined as Gregorian:
if( json.calendarmodel === 'http://www.wikidata.org/entity/Q1985727' ) {
finalTime = gregorianTime;
}
// Time instance should be defined as Julian:
else if( json.calendarmodel === 'http://www.wikidata.org/entity/Q1985786' ) {
if( /Q1985786$/i.test( json.calendarmodel ) ) {
// Since the data value saves the time as Gregorian, we first have to transform that back
// into Julian.
// NOTE: As of May 15 2013 we decided that this is nonsense and that we should always store
Expand All @@ -116,8 +112,9 @@ SELF.newFromJSON = function( json ) {
// todo: consider other fields, e.g. 'before', 'after' and 'utc'
);
}
// Time instance should be defined as Gregorian:
else {
throw new Error( 'Unknown calendar model "' + json.calendarmodel + '"' );
finalTime = gregorianTime;
}
return new SELF( finalTime );
};
Expand Down