Skip to content

Upgrade to rescript #101

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

Merged
merged 14 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ out
*.swp
*.swo

*.bs.js

# Generated via update-index script
public/blog/feed.xml

Expand All @@ -24,3 +22,6 @@ lib/
.vscode/

.vercel

# for IDE tooling tests
bin.exe
2 changes: 1 addition & 1 deletion _blogposts/2020-08-28-new-rescript-logo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: |
Today, our resident designer Bettina is unveiling to us the fresh new ReScript branding we've been long waiting for. We hope you're as excited about the result as us!
---

import Image from "components/Image.bs";
import Image from "components/Image";

## Why the Rebranding?

Expand Down
2 changes: 1 addition & 1 deletion _blogposts/archive/state-of-reasonml-org-2020-q2-pt1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: |
to expect in the future. The first part is an introduction to our project.
---

import Image from "components/Image.bs";
import Image from "components/Image";

## Hello World!

Expand Down
2 changes: 1 addition & 1 deletion _blogposts/archive/state-of-reasonml-org-2020-q2-pt3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: |
talk about upcoming tools and features.
---

import Image from "components/Image.bs";
import Image from "components/Image";

## Future Tools for the Community

Expand Down
2 changes: 1 addition & 1 deletion _blogposts/archive/state-of-reasonml-org-2020-q2-pt4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: |
This is the final part of the series about our vision of a more accessible Reason platform.
---

import Image from "components/Image.bs";
import Image from "components/Image";

## It's all Opinions

Expand Down
143 changes: 143 additions & 0 deletions bindings/IntlDateTimeFormat.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 0 additions & 83 deletions bindings/IntlDateTimeFormat.re

This file was deleted.

71 changes: 71 additions & 0 deletions bindings/IntlDateTimeFormat.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
type intl

/* Supported locales */
@bs.deriving({jsConverter: newType})
type locale = [@bs.as("zh") #CH | @bs.as("ru-RU") #RUS | @bs.as("sv-SE") #SWE | @bs.as("en-US") #US]

module Date = {
module Weekday = {
@bs.deriving({jsConverter: newType})
type t = [#long | #short | #narrow]

let make = value => tToJs(value)
}

module Era = {
@bs.deriving({jsConverter: newType})
type t = [#long | #short | #narrow]

let make = value => tToJs(value)
}

module Year = {
@bs.deriving({jsConverter: newType})
type t = [#numeric | @bs.as("2-digit") #twoDigit]

let make = value => tToJs(value)
}

module Day = {
@bs.deriving({jsConverter: newType})
type t = [#numeric | @bs.as("2-digit") #twoDigit]

let make = value => tToJs(value)
}

module Month = {
/* Helper for month option */
@bs.deriving({jsConverter: newType})
type t = [#long | #short | #narrow | #numeric | @bs.as("2-digit") #twoDigit]

let make = value => tToJs(value)
}

/* Options for Intl.DateTimeFormat */
@bs.deriving(abstract)
type options = {
@bs.optional
weekday: Weekday.abs_t,
@bs.optional
era: Era.abs_t,
@bs.optional
year: Year.abs_t,
@bs.optional
day: Day.abs_t,
@bs.optional
month: Month.abs_t,
}

/*
Intl.DateTimeFormat
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
*/
@bs.new @bs.scope("Intl")
external dateTimeFormat: (abs_locale, option<options>) => intl = "DateTimeFormat"

/* Intl.DateTimeFormat.prototype.format() */
@bs.send external format: (intl, Js.Date.t) => string = "format"

let make = (~locale=#US, ~options=?, date) =>
dateTimeFormat(localeToJs(locale), options)->format(date)
}
42 changes: 42 additions & 0 deletions bindings/Next.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading