@@ -14,13 +14,13 @@ use crate::foundations::{
1414} ;
1515use crate :: World ;
1616
17- /// Represents a date, a time, or a combination of both.
17+ /// 日付、時刻、またはその両方を表します。
1818///
19- /// Can be created by either specifying a custom datetime using this type's
20- /// constructor function or getting the current date with
21- /// [`datetime.today`]($datetime.today).
19+ /// この型のコンストラクタ関数を使ってカスタム日時を指定するか、
20+ /// [`datetime.today`]($datetime.today)を使って現在の日付を
21+ /// 取得することで作成できます。
2222///
23- /// # Example
23+ /// # 例
2424/// ```example
2525/// #let date = datetime(
2626/// year: 2020,
@@ -45,17 +45,17 @@ use crate::World;
4545/// )
4646/// ```
4747///
48- /// # Datetime and Duration
49- /// You can get a [duration] by subtracting two datetime:
48+ /// # DatetimeとDuration
49+ /// 2つのdatetimeの差を取ることで、 [duration]を取得できます。
5050/// ```example
5151/// #let first-of-march = datetime(day: 1, month: 3, year: 2024)
5252/// #let first-of-jan = datetime(day: 1, month: 1, year: 2024)
5353/// #let distance = first-of-march - first-of-jan
5454/// #distance.hours()
5555/// ```
5656///
57- /// You can also add/subtract a datetime and a duration to retrieve a new,
58- /// offset datetime:
57+ /// datetimeとdurationを加減算することで、新しい日時(オフセットされたdatetime)
58+ /// を取得することもできます。
5959/// ```example
6060/// #let date = datetime(day: 1, month: 3, year: 2024)
6161/// #let two-days = duration(days: 2)
@@ -67,72 +67,69 @@ use crate::World;
6767/// #two-days-later.display()
6868/// ```
6969///
70- /// # Format
71- /// You can specify a customized formatting using the
72- /// [`display`]($datetime.display) method. The format of a datetime is
73- /// specified by providing _components_ with a specified number of _modifiers_.
74- /// A component represents a certain part of the datetime that you want to
75- /// display, and with the help of modifiers you can define how you want to
76- /// display that component. In order to display a component, you wrap the name
77- /// of the component in square brackets (e.g. `[[year]]` will display the year).
78- /// In order to add modifiers, you add a space after the component name followed
79- /// by the name of the modifier, a colon and the value of the modifier (e.g.
80- /// `[[month repr:short]]` will display the short representation of the month).
70+ /// # フォーマット
71+ /// [`display`]($datetime.display)メソッドを使うことで、日時をカスタマイズして表示する
72+ /// フォーマットを指定できます。日時のフォーマットは、_コンポーネント_に_修飾子_を組み合わせる
73+ /// ことで指定します。
74+ /// コンポーネントは、日時の中の特定の部分(たとえば年や月など)を表します。そして修飾子を
75+ /// 使うことで、そのコンポーネントをどのように表示するかを細かく設定できます。
76+ /// コンポーネントを表示するには、コンポーネントの名前を角かっこで囲みます(例:`[[year]]`は
77+ /// 年を表示します)。修飾子を追加するには、コンポーネント名の後に半角スペースを入れ、
78+ /// 修飾子名、コロン(:)、修飾子の値を記述します(例:`[[month repr:short]]`は月名を
79+ /// 短縮形で表示します)。
8180///
82- /// The possible combination of components and their respective modifiers is as
83- /// follows:
81+ /// 使用可能なコンポーネントと修飾子の組み合わせは以下のとおりです。
8482///
85- /// - `year`: Displays the year of the datetime.
86- /// - `padding`: Can be either `zero`, `space` or `none`. Specifies how the
87- /// year is padded.
88- /// - `repr` Can be either `full` in which case the full year is displayed or
89- /// `last_two` in which case only the last two digits are displayed.
90- /// - `sign`: Can be either `automatic` or `mandatory`. Specifies when the
91- /// sign should be displayed.
92- /// - `month`: Displays the month of the datetime.
93- /// - `padding`: Can be either `zero`, `space` or `none`. Specifies how the
94- /// month is padded.
95- /// - `repr`: Can be either `numerical`, `long` or `short`. Specifies if the
96- /// month should be displayed as a number or a word. Unfortunately, when
97- /// choosing the word representation, it can currently only display the
98- /// English version. In the future, it is planned to support localization.
99- /// - `day`: Displays the day of the datetime.
100- /// - `padding`: Can be either `zero`, `space` or `none`. Specifies how the
101- /// day is padded.
102- /// - `week_number`: Displays the week number of the datetime.
103- /// - `padding`: Can be either `zero`, `space` or `none`. Specifies how the
104- /// week number is padded.
105- /// - `repr`: Can be either `ISO`, `sunday` or `monday`. In the case of `ISO`,
106- /// week numbers are between 1 and 53, while the other ones are between 0
107- /// and 53.
108- /// - `weekday`: Displays the weekday of the date.
109- /// - `repr` Can be either `long`, `short`, `sunday` or `monday`. In the case
110- /// of `long` and `short`, the corresponding English name will be displayed
111- /// (same as for the month, other languages are currently not supported). In
112- /// the case of `sunday` and `monday`, the numerical value will be displayed
113- /// (assuming Sunday and Monday as the first day of the week, respectively).
114- /// - `one_indexed`: Can be either `true` or `false`. Defines whether the
115- /// numerical representation of the week starts with 0 or 1.
116- /// - `hour`: Displays the hour of the date.
117- /// - `padding`: Can be either `zero`, `space` or `none`. Specifies how the
118- /// hour is padded.
119- /// - `repr`: Can be either `24` or `12`. Changes whether the hour is
120- /// displayed in the 24-hour or 12-hour format.
121- /// - `period`: The AM/PM part of the hour
122- /// - `case`: Can be `lower` to display it in lower case and `upper` to
123- /// display it in upper case.
124- /// - `minute`: Displays the minute of the date.
125- /// - `padding`: Can be either `zero`, `space` or `none`. Specifies how the
126- /// minute is padded.
127- /// - `second`: Displays the second of the date.
128- /// - `padding`: Can be either `zero`, `space` or `none`. Specifies how the
129- /// second is padded.
83+ /// - `year`: `datetime`の年を表示します。
84+ /// - `padding`: 年表示のパディングは`zero`(ゼロ)、`space`
85+ /// (空白)、`none`(なし)が指定できます。
86+ /// - `repr`: `full`(4桁表示)`last_two`(2桁表示)を指定できます。
87+ /// - `sign`: 符号の表示を`automatic`(自動)または`mandatory`(常時)で指定できます。
88+ /// - `month`: `datetime`の月を表示します
89+ /// - `padding`: 月表示のパディングは`zero`(ゼロ)、`space`
90+ /// (空白)、`none`(なし)が指定できます。
91+ /// - `repr`: 月を数値で表示するか(`numerical`)、英語の月名
92+ /// (`long`)、英語の略称(`short`)で表示するかを指定できます。
93+ /// 残念ながら、現在のところ、月名表示は英語のみです。将来的には
94+ /// ローカライズが予定されています。
95+ /// - `day`: `datetime`の日を表示します。
96+ /// - `padding`: 日表示のパディングは`zero`(ゼロ)、`space`
97+ /// (空白)、`none`(なし)が指定できます。
98+ /// - `week_number`: datetimeの週番号を表示します。
99+ /// - `padding`: 週番号のパディングは`zero`(ゼロ)、`space`
100+ /// (空白)、`none`(なし)が指定できます。
101+ /// - `repr`: `ISO`、`sunday`(日曜開始)、`monday`(月曜開始)
102+ /// を指定できます。ISOの場合、数字は1〜53、それ以外では0〜53で
103+ /// 表されます。
104+ /// - `weekday`: `date`の曜日を表示します。
105+ /// - `repr`: 曜日名(`long`)、曜日名の略称(`short`)、
106+ /// 日曜(`sunday`)、月曜(`monday`)のいずれかを指定できます。
107+ /// `long`と`short`では、対応する曜日名が英語で表示されます。
108+ /// (月名と同様に、他言語での表示はまだサポートされていません)。
109+ /// `sunday`と`monday`では、日曜または月曜から数えた日数が数値
110+ /// で表示されます
111+ /// - `one_indexed`: `true`または`false`を指定できます。これは、
112+ /// 曜日の数値表示の際、開始日を0とするか1とするかを指定します。
113+ /// - `hour`: `date`の時を表示します。
114+ /// - `padding`: 時表示のパディングは`zero`(ゼロ)、`space`
115+ /// (空白)、`none`(なし)が指定できます。
116+ /// - `repr`: 24時間表示(`24`)または12時間表示(`12`)を指定
117+ /// できます。
118+ /// - `period`: AM/PM(午前・午後)の表示です。
119+ /// - `case`: 小文字(`lower`)、大文字(`upper`)を指定できます。
120+ /// - `minute`: `date`の分を表示します。
121+ /// - `padding`: 分表示のパディングは`zero`(ゼロ)、`space`
122+ /// (空白)、`none`(なし)が指定できます。
123+ /// - `second`: `date`の秒を表示します。
124+ /// - `padding`: 秒表示のパディングは`zero`(ゼロ)、`space`
125+ /// (空白)、`none`(なし)が指定できます。
130126///
131- /// Keep in mind that not always all components can be used. For example, if you
132- /// create a new datetime with `{datetime(year: 2023, month: 10, day: 13)}`, it
133- /// will be stored as a plain date internally, meaning that you cannot use
134- /// components such as `hour` or `minute`, which would only work on datetimes
135- /// that have a specified time.
127+ /// すべてのコンポーネントが常に使用できるとは限らない点には注意して
128+ /// ください。たとえば、`{datetime(year: 2023, month: 10, day:
129+ /// 13)}`のようにして新しい`datetime`を作成すると、内部的には
130+ /// 日付のみが保持されるため、`hour`や`minute`のようなコンポーネント
131+ /// は使用できません。それらは特定の時刻が指定された`datetime`でのみ
132+ /// 動作します。
136133#[ ty( scope, cast) ]
137134#[ derive( Debug , Clone , Copy , PartialEq , Hash ) ]
138135pub enum Datetime {
@@ -233,20 +230,19 @@ impl Datetime {
233230
234231#[ scope]
235232impl Datetime {
236- /// Creates a new datetime.
233+ /// 新しい datetime を作成。
237234 ///
238- /// You can specify the [datetime] using a year, month, day, hour, minute,
239- /// and second.
235+ /// 年、月、日、時、分、秒を指定して[datetime]を作成します。
240236 ///
241- /// _Note_: Depending on which components of the datetime you specify, Typst
242- /// will store it in one of the following three ways:
243- /// * If you specify year, month and day, Typst will store just a date.
244- /// * If you specify hour, minute and second, Typst will store just a time.
245- /// * If you specify all of year, month, day, hour, minute and second, Typst
246- /// will store a full datetime.
237+ /// _注_:指定する` datetime`の要素によって、Typstが保持する
238+ /// 形式は次の3通りのいずれかになります。
239+ /// * 年、月、日だけを指定した場合、Typstは日付のみを保持します。
240+ /// * 時、分、秒だけを指定した場合、Typstは時刻のみを保持します。
241+ /// * 年、月、日、時、分、秒すべてを指定した場合、 Typst は完全な
242+ /// 日時を保持します。
247243 ///
248- /// Depending on how it is stored, the [`display`]($datetime.display) method
249- /// will choose a different formatting by default.
244+ /// 保持形式に応じて、 [`display`]($datetime.display)
245+ /// メソッドはデフォルトで異なるフォーマットを選択します。
250246 ///
251247 /// ```example
252248 /// #datetime(
@@ -257,22 +253,22 @@ impl Datetime {
257253 /// ```
258254 #[ func( constructor) ]
259255 pub fn construct (
260- /// The year of the datetime.
256+ /// ` datetime`の年
261257 #[ named]
262258 year : Option < i32 > ,
263- /// The month of the datetime.
259+ /// ` datetime`の月
264260 #[ named]
265261 month : Option < Month > ,
266- /// The day of the datetime.
262+ /// ` datetime`の日
267263 #[ named]
268264 day : Option < u8 > ,
269- /// The hour of the datetime.
265+ /// ` datetime`の時
270266 #[ named]
271267 hour : Option < u8 > ,
272- /// The minute of the datetime.
268+ /// ` datetime`の分
273269 #[ named]
274270 minute : Option < u8 > ,
275- /// The second of the datetime.
271+ /// ` datetime`の秒
276272 #[ named]
277273 second : Option < u8 > ,
278274 ) -> StrResult < Datetime > {
@@ -310,7 +306,7 @@ impl Datetime {
310306 } )
311307 }
312308
313- /// Returns the current date.
309+ /// 現在の日付を取得。
314310 ///
315311 /// ```example
316312 /// Today's date is
@@ -319,8 +315,8 @@ impl Datetime {
319315 #[ func]
320316 pub fn today (
321317 engine : & mut Engine ,
322- /// An offset to apply to the current UTC date. If set to `{auto}`, the
323- /// offset will be the local offset.
318+ /// 現在のUTC日時に適用するオフセットです。 `{auto}` に設定
319+ /// した場合は、ローカルのオフセットが適用されます。
324320 #[ named]
325321 #[ default]
326322 offset : Smart < i64 > ,
@@ -331,19 +327,22 @@ impl Datetime {
331327 . ok_or ( "unable to get the current date" ) ?)
332328 }
333329
334- /// Displays the datetime in a specified format.
330+ /// 指定したフォーマットで`datetime`を表示します。
331+ /// 日付のみ、時刻のみ、または両方が指定されているかによって、
332+ /// デフォルトのフォーマットは異なります。
333+ /// 日付のみ指定されている場合は`[[year]-[month]-[day]]`に
334+ /// なります。
335+ /// 時刻のみ指定されている場合は`[[hour]:[minute]:[second]]`
336+ /// になります。
337+ /// 日時の両方が指定されている場合は`[[year]-[month]-[day] [hour]:[minute]:[second]]`
338+ /// になります。
335339 ///
336- /// Depending on whether you have defined just a date, a time or both, the
337- /// default format will be different. If you specified a date, it will be
338- /// `[[year]-[month]-[day]]`. If you specified a time, it will be
339- /// `[[hour]:[minute]:[second]]`. In the case of a datetime, it will be
340- /// `[[year]-[month]-[day] [hour]:[minute]:[second]]`.
341- ///
342- /// See the [format syntax]($datetime/#format) for more information.
340+ /// 詳細は[フォーマット構文]($datetime/#format)を参照して
341+ /// ください。
343342 #[ func]
344343 pub fn display (
345344 & self ,
346- /// The format used to display the datetime.
345+ /// ` datetime`を表示する際に使用するフォーマットです。
347346 #[ default]
348347 pattern : Smart < DisplayPattern > ,
349348 ) -> StrResult < EcoString > {
@@ -366,7 +365,8 @@ impl Datetime {
366365 result. map ( EcoString :: from) . map_err ( format_time_format_error)
367366 }
368367
369- /// The year if it was specified, or `{none}` for times without a date.
368+ /// 年を返します。年が指定されていない場合や、日付を持たない時間の
369+ /// 場合は`{none}`になります。
370370 #[ func]
371371 pub fn year ( & self ) -> Option < i32 > {
372372 match self {
@@ -376,7 +376,7 @@ impl Datetime {
376376 }
377377 }
378378
379- /// The month if it was specified, or `{none}` for times without a date.
379+ /// 月を返します。日付を持たない時間の場合は `{none}`になります。
380380 #[ func]
381381 pub fn month ( & self ) -> Option < u8 > {
382382 match self {
@@ -386,7 +386,7 @@ impl Datetime {
386386 }
387387 }
388388
389- /// The weekday (counting Monday as 1) or `{none}` for times without a date.
389+ /// 曜日を返します。日付を持たない時間の場合は `{none}`になります。
390390 #[ func]
391391 pub fn weekday ( & self ) -> Option < u8 > {
392392 match self {
@@ -396,7 +396,7 @@ impl Datetime {
396396 }
397397 }
398398
399- /// The day if it was specified, or `{none}` for times without a date.
399+ /// 日を返します。日付を持たない時間の場合は `{none}`になります。
400400 #[ func]
401401 pub fn day ( & self ) -> Option < u8 > {
402402 match self {
@@ -406,7 +406,7 @@ impl Datetime {
406406 }
407407 }
408408
409- /// The hour if it was specified, or `{none}` for dates without a time.
409+ /// 時を返します。時刻を持たない日付の場合は `{none}`になります。
410410 #[ func]
411411 pub fn hour ( & self ) -> Option < u8 > {
412412 match self {
@@ -416,7 +416,7 @@ impl Datetime {
416416 }
417417 }
418418
419- /// The minute if it was specified, or `{none}` for dates without a time.
419+ /// 分を返します。時刻を持たない日付の場合は `{none}`になります。
420420 #[ func]
421421 pub fn minute ( & self ) -> Option < u8 > {
422422 match self {
@@ -426,7 +426,7 @@ impl Datetime {
426426 }
427427 }
428428
429- /// The second if it was specified, or `{none}` for dates without a time.
429+ /// 秒を返します。時刻を持たない日付の場合は `{none}`になります。
430430 #[ func]
431431 pub fn second ( & self ) -> Option < u8 > {
432432 match self {
@@ -436,7 +436,8 @@ impl Datetime {
436436 }
437437 }
438438
439- /// The ordinal (day of the year), or `{none}` for times without a date.
439+ /// 年の通算日(1年の中での通し番号)を返します。
440+ /// 日付を持たない時刻の場合は `{none}` になります。
440441 #[ func]
441442 pub fn ordinal ( & self ) -> Option < u16 > {
442443 match self {
0 commit comments