-
-
Notifications
You must be signed in to change notification settings - Fork 408
Added icelandic, along with tests #225
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
Open
olitomas
wants to merge
4
commits into
hustcc:master
Choose a base branch
from
olitomas:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b134c42
Added icelandic, along with tests
olitomas 623e035
Fix for quirky icelandic rule where singular is to be used if the las…
olitomas b3df3fd
Fix to logic after help from the icelandic software community on FB (…
olitomas 70b49c8
Fixed contact info
olitomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ esm | |
dist | ||
|
||
timeago.full.min.js | ||
timeago.min.js | ||
timeago.min.js | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/** | ||
* Created by hustcc on 18/5/24. | ||
* Contact: [email protected] | ||
*/ | ||
olitomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { advanceTo, clear } from 'jest-date-mock'; | ||
import { format, register } from '../../src'; | ||
import is from '../../src/lang/is'; | ||
|
||
register('is', is); | ||
|
||
let date = new Date(); | ||
|
||
beforeEach(() => { | ||
advanceTo(0); | ||
date = new Date(); | ||
}); | ||
afterEach(() => { | ||
clear(); | ||
}); | ||
describe('is', () => { | ||
test('time ago', () => { | ||
advanceTo(9 * 1000); | ||
expect(format(date, 'is')).toEqual('rétt í þessu'); | ||
|
||
advanceTo(30 * 1000); | ||
expect(format(date, 'is')).toEqual('30 sekúndum síðan'); | ||
|
||
advanceTo(1000 * 60); | ||
expect(format(date, 'is')).toEqual('1 mínútu síðan'); | ||
|
||
advanceTo(1000 * 60 * 30); | ||
expect(format(date, 'is')).toEqual('30 mínútum síðan'); | ||
|
||
advanceTo(1000 * 60 * 60); | ||
expect(format(date, 'is')).toEqual('1 klukkutíma síðan'); | ||
|
||
advanceTo(1000 * 60 * 60 * 8); | ||
expect(format(date, 'is')).toEqual('8 klukkutímum síðan'); | ||
|
||
advanceTo(1000 * 60 * 60 * 24); | ||
expect(format(date, 'is')).toEqual('1 degi síðan'); | ||
|
||
advanceTo(1000 * 60 * 60 * 24 * 3); | ||
expect(format(date, 'is')).toEqual('3 dögum síðan'); | ||
|
||
advanceTo(1000 * 60 * 60 * 24 * 7); | ||
expect(format(date, 'is')).toEqual('1 viku síðan'); | ||
|
||
advanceTo(1000 * 60 * 60 * 24 * 7 * 3); | ||
expect(format(date, 'is')).toEqual('3 vikum síðan'); | ||
|
||
advanceTo(1000 * 60 * 60 * 24 * 31); | ||
expect(format(date, 'is')).toEqual('1 mánuði síðan'); | ||
|
||
advanceTo(1000 * 60 * 60 * 24 * 31 * 4); | ||
expect(format(date, 'is')).toEqual('4 mánuðum síðan'); | ||
|
||
advanceTo(1000 * 60 * 60 * 24 * 366); | ||
expect(format(date, 'is')).toEqual('1 ári síðan'); | ||
|
||
advanceTo(1000 * 60 * 60 * 24 * 366 * 10); | ||
expect(format(date, 'is')).toEqual('10 árum síðan'); | ||
}); | ||
test('time in', () => { | ||
advanceTo(-9 * 1000); | ||
expect(format(date, 'is')).toEqual('núna'); | ||
|
||
advanceTo(-30 * 1000); | ||
expect(format(date, 'is')).toEqual('eftir 30 sekúndur'); | ||
|
||
advanceTo(-21 * 1000); | ||
expect(format(date, 'is')).toEqual('eftir 21 sekúndu'); | ||
|
||
advanceTo(-1000 * 60); | ||
expect(format(date, 'is')).toEqual('eftir 1 mínútu'); | ||
|
||
advanceTo(-1000 * 60 * 30); | ||
expect(format(date, 'is')).toEqual('eftir 30 mínútur'); | ||
|
||
advanceTo(-1000 * 60 * 31); | ||
expect(format(date, 'is')).toEqual('eftir 31 mínútu'); | ||
|
||
advanceTo(-1000 * 60 * 60); | ||
expect(format(date, 'is')).toEqual('eftir 1 klukkutíma'); | ||
|
||
advanceTo(-1000 * 60 * 60 * 8); | ||
expect(format(date, 'is')).toEqual('eftir 8 klukkutíma'); | ||
|
||
advanceTo(-1000 * 60 * 60 * 24); | ||
expect(format(date, 'is')).toEqual('eftir 1 dag'); | ||
|
||
advanceTo(-1000 * 60 * 60 * 24 * 3); | ||
expect(format(date, 'is')).toEqual('eftir 3 daga'); | ||
|
||
advanceTo(-1000 * 60 * 60 * 24 * 7); | ||
expect(format(date, 'is')).toEqual('eftir 1 viku'); | ||
|
||
advanceTo(-1000 * 60 * 60 * 24 * 7 * 3); | ||
expect(format(date, 'is')).toEqual('eftir 3 vikur'); | ||
|
||
advanceTo(-1000 * 60 * 60 * 24 * 31); | ||
expect(format(date, 'is')).toEqual('eftir 1 mánuð'); | ||
|
||
advanceTo(-1000 * 60 * 60 * 24 * 31 * 4); | ||
expect(format(date, 'is')).toEqual('eftir 4 mánuði'); | ||
|
||
advanceTo(-1000 * 60 * 60 * 24 * 366); | ||
expect(format(date, 'is')).toEqual('eftir 1 ár'); | ||
|
||
advanceTo(-1000 * 60 * 60 * 24 * 366 * 10); | ||
expect(format(date, 'is')).toEqual('eftir 10 ár'); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const is = ['sekúnd', 'mínút', 'klukkutím', 'd', 'vik', 'mánuð', 'ár']; | ||
const plural_in = ['ur', 'ur', 'a', 'aga', 'ur', 'i', '']; | ||
const plural_ago = ['um', 'um', 'um', 'ögum', 'um', 'um', 'um']; | ||
|
||
const singular_in = ['u', 'u', 'a', 'ag', 'u', '', '']; | ||
const singular_ago = ['u', 'u', 'a', 'egi', 'u', 'i', 'i']; | ||
|
||
export default function(diff: number, idx: number): [string, string] { | ||
if (idx === 0) return ['rétt í þessu', 'núna']; | ||
const is_indx = Math.floor(idx / 2); | ||
const unit = is[is_indx]; | ||
let unit_in, unit_ago; | ||
if (diff % 10 === 1 && diff !== 11) { | ||
unit_in = singular_in[is_indx]; | ||
unit_ago = singular_ago[is_indx]; | ||
} else { | ||
unit_in = plural_in[is_indx]; | ||
unit_ago = plural_ago[is_indx]; | ||
} | ||
|
||
return [`${diff} ${unit + unit_ago} síðan`, `eftir ${diff} ${unit + unit_in}`]; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.