メインコンテンツまでスキップ

SenseTalkの日付と時間の値

SenseTalkは、日付と時間を操作するためのコマンドと関数を含んでいます。一つの日付または時間から別の日付または時間をマイナス( - )演算子を使用して減算し、その差を秒で得ることができます。時間間隔を日付または時間に追加することで、新しい日付/時間値を得ることも可能です(時間間隔の追加と減算を参照してください)。

日付、時間、および時間間隔

SenseTalkでは、「日付」と「時間」の基本的な区別はありません - どちらも時間の流れの中の精密な瞬間、またはタイムライン上のポイントとして扱われます。その起源(ゼロ値)は2001年1月1日の始まりの真夜中に、調整世界時でした。その瞬間以前の任意の日付または時間は内部的には負の値として扱われ、後の時間は起源以降の秒数を示す正の値として扱われます。

SenseTalkは、「4/22/67」または「1967-04-22 18:00」のような多様な形式で表現された日付と時間を認識することができます。詳細については、the timeInputFormatグローバルプロパティを参照してください。Naturalフォーマットでは、さらに多くのバリエーションを許容し、「May 15, 2004 10:57 PM」、または"yesterday"、"today"、や"next Tuesday in the afternoon." などを許容します。 todaynow (引用符で囲まれていない)の単語は、現在の日付または現在の日付と時間を指示するために使用できます(それらが変数として使用され、他の値が割り当てられていない場合)。このフォーマットについての詳細情報については、Natural Formatを参照してください。

日付値が一日の時間を指定せずに提供されると、その日の正午を意味するとみなされます。日付なしで時間が指定されると、現在の日付(今日)の指定時間を意味するとみなされます。すべての日付と時間は、スクリプトが実行されているマシン上で現在設定されているローカルタイムゾーンであると想定されます。

_time interval_または_duration_は、時間の長さです。時間間隔を扱うとき、SenseTalkは特定の単位が与えられない場合、秒単位で測定された持続時間を想定しますが、週、日、時間、ミリ秒など、他の多くの単位も使用できます(Values内のTime Intervalsを参照してください)。

秒で正確に測定できる持続時間に加えて、SenseTalkは、月、calendarQuarters、calendarYearsなどを含む月を基準に測定された_calendar durations_ もサポートしています。使用可能なcalendarDuration単位の全リストを確認するには、次のコマンドを使用します:

put (each item of the unitNames whose unitType is calendarDuration) sorted

詳細については、Values内のCalendar Durations in Valuesを参照してください。

時間間隔とカレンダーの持続時間の両方を、過去または未来の時間値を生成するためのago and hence operatorsと一緒に使用できます。

ノート

日付と時間に実質的な違いはないため、この文書では、日付または時間を「日付/時間値」として参照することがあります。

SenseTalkには、スクリプト内の日付と時間の値の動作に影響を与えるために使用できるいくつかのグローバルまたはローカルプロパティが含まれています。これらのプロパティは以下の概念の説明で言及されています。各プロパティの完全な定義は、Local and Global Properties for Working with Values で見つけることができます。具体的なプロパティは以下のとおりです:

  • The ClockFormat
  • The TimeFormat
  • The TimeInputFormat
  • The CenturyCutoff
  • The LastDayOfMonthCalculation

日付/時間の算術

時間間隔の追加と減算

任意の日付(または時間)から始めて、時間間隔を単純に追加または減算することにより、異なる日付/時間を取得することができます。

例:

put today + 2 weeks into dueDate

例:

subtract 3 hours 14 minutes 22 seconds from timer

日付または時間の差の計算

一つの日付または時間の値を別のものから引くことにより、日付間の日数や何かのプロセスにかかる経過時間を簡単に計算することができます。差は常に秒単位の時間間隔として表現されますが、それを(1 dayのような時間間隔の表現を使用して)その単位の秒数で割ることにより、異なる単位(例えば日)に変換することができます。

例:

put (expirationDate - "today") / 1 day into daysRemaining -- results in a pure number
put (expirationDate - "today") as days into daysRemaining -- results in a number with units of days

例:

put the time into startTime -- Start timing here
run somethingTimeConsuming -- Whatever you want to time
put the time - startTime into secondsElapsed

日付または時間の比較

SenseTalkの比較演算子(is=comes before<など)は、通常、比較される二つの値をテキストとして扱います。ただし、それらがどちらも数字であるか、あるいはそれらがどちらも日付または時間の値であると「知っている」場合を除きます。比較は通常、値をテキストとして扱いますので、以下のような場合には望ましい結果を得られません:

if the date is between "Sep 21" and "Dec 21" then put "Happy Autumn"

SenseTalkに日付または時間の比較を行わせるためには、date()またはtime()関数を使用してテキストを内部の日付/時間の表現に変換します。これがうまくいきます(年が指定されていない場合、現在の年が想定されるので、この例は任意の年で動作します):

if the date is between date ("Sep 21") and date ("Dec 21") then
put "Happy Autumn!"
end if

日付と時間を扱うためのコマンドと関数

以下に、SenseTalkで日付と時間の値を操作するために使用できる特定のコマンドと関数を示します。

Date, asDate関数

動作: 現在の日付、または与えられた式の日付値を返します。 long date関数は、現在の曜日と月のフルネームを含む日付の詳細なバージョンを返します。Abbreviated dateshort dateのバリエーションは、他の形式で日付を提供します。 date関数が返す値は、テキストに変換されると、自動的にフォーマットされた日付を表示します(例で示されています)。その値は、また、日付/時間の計算に使用するため、関数が呼び出された時の正確な日付と時間を表す数値として扱うこともできます。 dateExprが与えられた場合、その日の正午を表す値を返します(dateExprに1日の時間が含まれている場合、それは無視されます)。

asDate関数もdateExprの指定された値を日付に変換しますが、標準の日付形式を割り当てる代わりに、asDate関数はdateExpr自体の形式から形式を導き出します。asDate関数はas {a} date演算子を使用しても呼び出すことができます。

構文:
the { [ long | short | abbr{ev{iated}} ] } date {of dateExpr}
date( {dateExpr} )
asDate( dateExpr )

例:

put the date --> "10/07/95"
put the short date --> "10/7/95"
put the abbrev date --> "Sat, Oct 7, 1995"
put the long date --> "Saturday, October 7, 1995"

例:

put date("May 14, 1942") --> "05/14/42"

例:

put asDate("May 14, 1942") --> "May 14, 1942"

関連:

TimeZoneOffset, UTCOffset, SecondsFromGMT 関数

動作: 現地時間と協定世界時(UTC)との間の秒単位の差を返します(同義のsecondsFromGMTは歴史的な用語であるグリニッジ標準時(GMT)を参照します)。日付が1つ指定されて呼び出された場合、それは指定された日付でのUTCからの現地の差を返します(その日に夏時間が有効かどうかによって異なる可能性があります)。

put UTCOffset("June 4, 2001") / 1hour -- -6を返す

タイムゾーンを指定する際には、公式のID名(例:"America/Los_Angeles")、タイムゾーンの略称("PDT")、または名前の一部をスペースや特殊文字を無視して使うことができます(例:"los angeles")。

構文:
the [ TimeZoneOffset | UTCOffset | SecondsFromGMT ] {of aDateOrTimeZone}
[ TimeZoneOffset | UTCOffset | SecondsFromGMT ]( {aDateOrTimeZone} )
[ TimeZoneOffset | UTCOffset | SecondsFromGMT ]( aDate , aTimeZone )
[ TimeZoneOffset | UTCOffset | SecondsFromGMT ]( aTimeZone , aDate )

例:

put the TimeZoneOffset --> -7 hours   (example shown in Mountain Standard Time)
put the SecondsFromGMT --> -25200 (the same value as a plain number of seconds)
put the TimeZoneOffset of "July 1" --> -6 hours (July is in Mountain Daylight Time)

例:

put TimeZoneOffset("March 4, 2001", "Denver") --> -7 hours
put UTCOffset("Paris", "2023-07-10") --> 2 hours

例:

Seconds関数

動作: 2001年1月1日以来の現在の秒数を返します。long seconds関数は、現在の秒の部分を含む、秒数のより正確なバージョンを返します。abbreviated secondsshort secondsのバリエーションも利用可能で、それぞれマイクロ秒(6小数位)とミリ秒(3小数位)までの値を提供します。dateTimeValueが指定された場合、返される数値は、2001年1月1日の始まりから指定された時間までの秒数となります(指定された時間が2001年より前の場合、数値は負となります)。

構文:
the { [ long | short | abbr{ev{iated}} ] } seconds
the seconds {of dateTimeValue}
seconds( {dateTimeValue} )

例:

put the long seconds -- 62899676.90865231

例:

put the long seconds --> 62899676.90865231
put abbreviated seconds --> 62899676.908652
put the short seconds --> 62899676.908

関連:

Ticks関数

動作: SenseTalkエンジンが起動してからのtick数(1/60秒)を返します。

構文:
the ticks
ticks()

例:

if the ticks is greater than 36000 then
put "SenseTalk was started more than 10 minutes ago."
end if

関連:

Time, AsTime 関数

動作: 現在の時刻、または指定された表現の時間値を返します。 long time関数は、秒を含む時間の長いバージョンを返します。 Abbreviated timeshort timeのバリエーションは、他の形式で時間を提供します。

asTime関数も_timeExpr_で指定された値を時間に変換しますが、標準の時間形式を割り当てる代わりに、asTime関数は_timeExpr_自体の形式から形式を導き出します。asTime関数はas {a} timeオペレーターを使用して呼び出すこともできます。

構文:
the { [ long | short | abbr{ev{iated}} ] } time {of timeExpr}
time( {timeExpr} )
asTime( {timeExpr} )

例:

put the time --> 02:38 PM
put the short time --> 02:38
put the abbrev time --> 02:38:32
put the long time --> 02:38:32 PM

例:

put time("7:35:42")-- "07:35 AM"を表示

例:

put asTime("7:35:42") -- "07:35:42"を表示
Tech Talk

time関数によって返される値は、テキストに変換すると自動的にフォーマットされた時間を表示します。その値は、関数が呼び出された正確な日時(またはそのパラメーターによって表される正確な日時)を表す数値としても扱うことができます。これは、日時の計算や比較で使用されます。

the clockFormatグローバルプロパティが"24 hour"に設定されている場合、すべての時間関数が使用するフォーマットには"AM"や"PM"が含まれず、代わりに00から23の間の時間を表示します。

_timeExpr_が指定された場合、その値は評価され、内部の時間表現として返されます。

_timeExpr_が指定されると、その値が評価されて内部時間表現として返されます。これは他の変換関数と一貫性を保つため、asTimeという名前で呼び出すこともできます。

関連:

日付または時間のコンポーネント

以下の関数は、指定された日付または時間の個々のコンポーネントを提供します。また、パラメータなしで呼び出された場合、各関数は現在の日付または時間の特定のコンポーネントを返します。例えば:

  • the hourは現在の時間を返します
  • the hour of "8.45 AM"は指定された時間の時間要素を返します。この場合、8です。

Year関数

動作: 指定された日付の年数、または現在の年を返します。

構文:
the year {of dateTimeValue}
year( {dateTimeValue} )

例:

put the year into currentYear

例:

put the dayOfYear of "4 July 1776" -- "186" (the 186th day of the year)

関連:

Month関数

動作: 指定された日付の月の数(1から12まで)、または現在の月を返します。

構文:
the month {of dateTimeValue}
month( {dateTimeValue} )

例:

put the month into monthNum

例:

put month("4 July 1776") -- "7"

関連:

MonthName関数

動作: 指定された日付の月名、または現在の月を返します。

構文:
the monthName {of dateTimeValue}
monthName( {dateTimeValue} )

例:

put monthName() into monthName

例:

put the monthName of "27 April 2022" --> "April"

関連:

Day関数

動作: 指定された日付の日数(1から31まで)、または現在の日付を返します。

構文:
the day {of dateTimeValue}
day( {dateTimeValue} )

例:

put day() into dayNum

例:

put year("4 July 1776") -- "1776"

関連:

WeekdayName関数

動作: 指定された日付の曜日名、または現在の日付を返します。

構文:
the weekdayName {of dateTimeValue}
weekdayName( {dateTimeValue} )

例:

put weekdayName() into dayName

例:

put the weekdayName of "27 April 2022" -- "Wednesday"

関連:

DayOfWeek関数

動作: 指定された日付、または現在の日付の曜日番号(1から7まで)を返します。週の最初の日、番号1は、システムの設定によって決まります。

構文:
the dayOfWeek {of dateTimeValue}
dayOfWeek( {dateTimeValue} )

例:

put dayOfWeek() into weekdayNum

例:

put the dayOfWeek of "4 July 1776" -- "5" (Thursday)

関連:

DayOfYear関数

動作: 指定された日付、または現在の日付の年内日数(1から366まで)を返します。

構文: the dayOfYear {of dateTimeValue}
dayOfYear( {dateTimeValue} )

例:

put dayOfYear() into dayNum

例:

put the day of "4 July 1776" -- "4"

関連:

DayOfCommonEra関数

動作: 指定された日付、または現在の日付の共通時代(年1の1月1日)以降の日数を返します。この関数は任意の二つの日付間の経過日数を計算するのに便利です。

構文:
the dayOfCommonEra {of dateTimeValue}
dayOfCommonEra( {dateTimeValue} )

例:

put the dayOfCommonEra into todayNum

例:

put dayOfCommonEra("4 July 1776") -- shows "648491"

例:

put "The U.S. has been independent for "& \
dayOfCommonEra() - dayOfCommonEra("4 July 1776") &" days"

関連:

Hour関数

動作: 指定された時間値、または現在の時間の時間番号(0から23まで)を返します。

構文:
the hour {of dateTimeValue}
hour( {dateTimeValue} )

例:

put the hour into hourNum

例:

put hour("5:37:22 PM") -- "17"

関連:

Minute関数

動作: 指定された時間値、または現在の時間の分数(0から59まで)を返します。

構文:
the minute {of dateTimeValue}
minute( {dateTimeValue} )

例:

put minute() into minutesPastTheHour

例:

put the minute of "5:37:22 PM" -- "37"

関連:

Second関数

動作: 指定された時間、または現在の時間の秒数(0から59まで)を返します。

構文:
the second {of dateTimeValue}
second( {dateTimeValue} )

例:

put the second into currentSecondNumber

例:

put second("5:37:22 PM") -- "22"
ノート

second()関数が返す値は常に0から59までの数値になります。これは、2001年1月1日の開始からの秒数を返すseconds()関数とは大きく異なります。

関連:

Millisecond, Microsecond関数

動作:

  • millisecond関数: 指定された時間、または現在の時間のミリ秒数(0から999まで)を返します。ミリ秒は秒の千分の一です。
  • microsecond関数: 指定された時間、または現在の時間のマイクロ秒数(0から999999まで)を返します。マイクロ秒は秒の百万分の一です。

構文:
the { [ long | short | abbr{ev{iated}} ] } monthNames
monthNames()
the { [ long | short | abbr{ev{iated}} ] } weekDayNames
weekDayNames()

例:

put millisecond() into currentMillisecond

例:

put the millisecond of startTime

例:

set tempName to the hour& the minute& the second& the microsecond

例:

put microsecond(previousTime)

関連:

Date と Time の形式

SenseTalkは、さまざまな形式で日付と時刻を表現することができます。このセクションのコマンドや関数は、これらの異なる形式で動作します。

Convertコマンド

動作: convertコマンドは日付/時間の値を異なる日付/時間の形式に変換します。変換される元の値がコンテナである場合、コンテナの内容は変換後の値で置き換えられます。それ以外の場合、結果は変数itに格納されます。

どちらの場合でも(秒の形式に変換する場合を除く)、結果の値は内部的には要求された形式の日付/時間の値となります。この形式を使うと、結果から時間の間隔を加算したり減算したりしても同じ形式を保持することができます。

実際に使用される形式は、the timeFormatグローバルプロパティで定義されており、必要に応じて変更することができます。秒の形式にはthe timeFormatの対応する値がないため、秒、長い秒などに変換すると、フォーマットされた時間値ではなく固定文字列となります。

Syntax:
convert source to formatName {and formatName}

以下のテーブルのFormat Name列に表示されている値を_formatName_として使用することができます。

形式名形式例の値
date[mo]/[da]/[yr]11/09/04
short date[m]/[d]/[yr]11/9/04
long date[weekday], [monthName] [day], [year]Tuesday, November 9, 2004
abbreviated date[wkday], [mon] [day], [year]Tue, Nov 9, 2004
time[hr12]:[mi] [pm]03:17 PM
short time[hr12]:[mi]03:17
long time[hr12]:[mi]:[se] [pm]03:17:25 PM
abbreviated time[hr12]:[mi]:[se]03:17:25
local time[hr12]:[mi] [pm] [timeZoneID]03:17 PM America/Denver
short local time[hr12]:[mi] [pm] [timeZone]03:17 PM -0700
long local time[hr12]:[mi]:[se] [pm] [timeZoneID]03:17:25 PM America/Denver
abbreviated local time[hr12]:[mi]:[se] [pm] [timeZone]03:17:25 PM -0700
dateitems[year],[mo],[da],[hr24],[mi],[se],[dayOfWeek]2004,11,09,15,17,25,2
short dateitems[year],[mo],[da],[hr24],[mi],[se]2004,11,09,15,17,25
long dateitems[year],[mo],[da],[hr24],[mi],[se],[dayOfWeek],[timeZoneID]2004,11,09,15,17,25,2, America/Denver
abbreviated dateitems[year],[mo],[da],[hr24],[mi],[se],[dayOfWeek],[timeZone]2004,11,09,15,17,25,2,-0700
simple date[mo]/[da]11/09
short simple date[m]/[d]11/9
long simple date[monthName] [day]November 9
abbreviated simple date[mon] [day]Nov 9
basic date[mon] [day], [year]Nov 9, 2004
short basic date[mon] [day] [yr]Nov 9 04
long basic date[monthName] [day], [year]November 9, 2004
abbreviated basic date[monthName] [day] [yr]November 9 04
basic time[mon] [day], [year] [hr12]:[mi] [pm]Nov 9, 2004 03:20 PM
short basic time[mon] [day] [yr] [hour12]:[mi] [pm]Nov 9 04 3:20 PM
long basic time[monthName] [day], [year] [hr12]:[mi]:[se] [pm]November 9, 2004 03:20:26 PM
abbreviated basic time[monthName] [day] [yr] [hr12]:[mi]:[se] [pm]November 9 04 03:20:26 PM
common date[d] [mon] [year]9 Nov 2004
short common date[d] [mon] [yr]9 Nov 04
long common date[da] [monthName] [year]09 November 2004
abbreviated common date[da] [mon] [year]09 Nov 2004
common time[d] [mon] [year] [hr12]:[mi] [pm]9 Nov 2004 08:29 AM
short common time[d] [mon] [yr] [hour12]:[mi] [pm]9 Nov 04 08:29 AM
long common time[da] [monthName] [year] [hr12]:[mi]:[se] [pm]09 November 2004 08:29 AM
abbreviated common time[da] [mon] [year] [hr12]:[mi]:[se] [pm]09 Nov 2004 08:29 AM
C time[wkday] [mon] [day] [hr24]:[mi]:[se] [year]Tue Nov 9 15:32:28 2004
short C time[mon] [day] [hr24]:[mi] [year]Nov 9 15:32 2004
long C time[weekday] [monthName] [day] [hr24]:[mi]:[se] [year]Tuesday November 9 15:32:28 2004
abbreviated C time[mon] [day] [hr24]:[mi]:[se] [year]Nov 9 15:32:28 2004
international date[year]-[mo]-[da]2004-11-09
short international date[year]-[mo]2004-11
long international date[year]-[mo]-[da]2004-11-09
abbreviated international date[year]-[mo]2004-11
international time[year]-[mo]-[da]T[hr24]:[mi]:[se][timeZone]2004-11-09T08:29:25-0700
short international time[year]-[mo]-[da]T[hr24]:[mi][timeZone]2004-11-09T08:29-0700
long international time[year]-[mo]-[da]T[hr24]:[mi]:[se].[millisecond][timeZone]2004-11-09T08:29:25.894-0700
abbreviated international time[year]-[mo]-[da] [hr24]:[mi]:[se] [timeZone]2004-11-09 08:29:25 -0700
internet date[wkday], [day] [mon] [year] [hr24]:[mi]:[se] [timeZone]Tue, 9 Nov 2004 08:29:25 -0700
short internet date[day] [mon] [year] [hr24]:[mi] [timeZone]9 Nov 2004 08:29 -0700
long internet date[day] [mon] [year] [hr24]:[mi] [timeZone]Tuesday, 9 November 2004 08:29:25 -0700
abbreviated internet date[day] [mon] [year] [hr24]:[mi]:[se] [timeZone]9 Nov 2004 08:29:25 -0700
UTC time or zulu time[year]-[mo]-[da] [hr24]:[mi]:[se] [timeZone]2004-11-09 15:29:25 +0000
short UTC time or short zulu time[hr24]:[mi] [timeZone]15:29 +0000
long UTC time or long zulu time[year]-[mo]-[da] [hr24]:[mi]:[se].[millisecond] [timeZone]2004-11-09 15:29:25.000 +0000
abbreviated UTC time or abbreviated zulu time[hr24]:[mi]:[se] [timeZone]15:29:25 +0000
military time[da] [hr24][mi][timeZoneISO] [mon] [yr]09 1529Z Nov 04
short military time[hr24][mi][timeZoneISO]1529Z
long military time[da] [hr24][mi][se][timeZoneISO] [mon] [yr]09 152925Z Nov 04
abbreviated military time[da] [hr24][mi][timeZoneISO]09 1529Z
seconds上記説明の固定文字列121732349
long seconds上記説明の固定文字列121732348.572803789
abbreviated seconds上記説明の固定文字列121732348.572804
short seconds上記説明の固定文字列121732348.573
ノート

UTCzulumilitaryのいずれかの時間形式に変換すると、結果の値のタイムゾーンもUTCに設定されます。

SenseTalkで日付/時間の形式がどのように定義されているかについての完全な情報については、SenseTalk Date and Time Formatsを参照してください。

例:

convert "8/14/02" to long date // "8/14/02" is not a container, so this sets the value of 'it'
put it --> Wednesday, August 14, 2002

例:

convert the time to short date and time // sets value of 'it'
put it --> 7/10/23 04:55 PM

例:

convert expirationDate to date -- expirationDateの値を変更

例:

convert line 2 of file "/tmp/resultLog" to abbreviated local time

日付と時間のすべての形式の正確な形式は、スクリプト内で適切なプロパティを設定することでカスタマイズできます。これについては、the timeFormatグローバルプロパティの説明で述べられています。Global and Local Properties for Working with Values

dateitems形式は、カレンダーの日付を扱うために特に便利であることができます。dateitems形式で表された日付/時間は、年、月、日、時間、分、秒、週の日(1は日曜日を表し、7は土曜日を表します)を表す7つの数字で、コンマで区切られています。long dateitemsおよびabbreviated dateitems形式にはタイムゾーン情報も含まれています。short dateitemsは週の日を省略します。

ここにdateitemsを使用した例があります - リープイヤーを扱うためにdateitemsを利用したdiscussion of Helpersで紹介されたcalculateAge関数に似たものです:

function calculateAge birthDate -- 指定したbirthDateの年齢を計算
convert birthDate to dateItems -- yr,mon,day,hr,min,secに変換
split birthDate by comma -- リストに変換
convert the date to dateItems -- 'it'の今日の日付をdateItemsに変換
split it by comma -- リストに変換
subtract birthDate from it -- 一方のリストの値を他方から減算
// 今日の月の日がbirthDateより小さい場合、月を1つ減らす:
if item 3 of it < 0 then subtract 1 from item 2 of it
// その後、今日の月がbirthDateより小さい場合、年を1つ減らす:
if item 2 of it < 0 then subtract 1 from item 1 of it
return item 1 of it -- 年の差
end calculateAge

the clockFormatグローバルプロパティが24 hourに設定されている場合、すべての時間形式は24時間制の時計形式(例:15:17)を使用します。このプロパティについての詳細情報については、Local and Global Properties for Working with Valuesを参照してください。

Basic Date, Basic Time関数, Common Date, Common Time関数, DateItems関数, International Date, International Time関数, Internet Date関数, Local Time関数, Simple Date関数, C Time関数

**動作:**これらの各関数は、現在の瞬間または指定された瞬間を表す形式化された値を返し、その形式は使用される特定の関数に特有のものです。各関数には四つのバリエーションがあり、関数名だけを使用するか、long, short, または abbreviated (これは abbrev または abbr に短縮できます)という形容詞のいずれかで前置します。異なるすべてのフォーマットは、上記の convert コマンドのテーブルに表示されます。

basic date 形式は月名(または省略形)で始まり、次に日付、最後に年を表示します。basic time形式では、日時が追加されます。

common date および common time 形式は basic 形式に似ていますが、月名の後ではなく前に日を表示します。

dateItems 形式は、日付と時間をコンマ区切りのテキストリストとして表示します。short dateItemsは六つの項目を返します:年、月、日、時間、分、秒。dateItems (形容詞なし)は、7つ目の項目が曜日(1-7、日曜日は1)である7つの項目を返します。abbreviated dateItemsは、時間帯のオフセットをHHMM形式で追加し、long dateItemsは同じ情報を返しますが、オフセットではなく時間帯名を表示します。dateItems関数が返す値は、テキストに変換すると自動的にフォーマットされた日付を表示します。その値はまた、関数が呼び出された正確な日付と時間を表す数値として扱うこともできます。これは日付/時間の計算に使用されます。

international date および international time 形式は、完全な日付、年と月、または完全な日付と時間を、国際的なISO 8601標準( http://www.ietf.org/rfc/rfc3339.txtを参照)に準拠した方法で表示します。ただし、abbreviatedinternationaltime は、インターネット上で広く使用されている形式を表示します。これは標準からわずかに異なります。

internet date形式は日付と時間を、インターネットメッセージ形式の日付と時間仕様に準拠した方法で表示します。これはRFC 2822 http://www.ietf.org/rfc/rfc2822.txtで定義されています。ただし、longinternetdate は完全な曜日と月名を表示します。

local time形式は、時間帯情報を含む現在の時刻を表示します。

simple date形式は、月と日だけを含む非常にシンプルな形式で日付を表示しますが、年は省略します。

C time (または CTime)形式は、Cベースのシステム(Pythonを含む)で使用される形式で日付と時間を表示します。

put the UTCOffset -- "-25200" を返す(MST内)

convert "8/14/02" to long date -- 'it'の値を設定

Syntax:
the { [ long | short | abbr{ev{iated}} ] } basic [date | time] {of dateExpr}
the { [ long | short | abbr{ev{iated}} ] } common [date | time] {of dateExpr}
the { [ long | short | abbr{ev{iated}} ] } dateItems {of dateExpr}
the { [ long | short | abbr{ev{iated}} ] } international [date | time] {of dateExpr}
the { [ long | short | abbr{ev{iated}} ] } internet date {of dateExpr} the { [ long | short | abbr{ev{iated}} ] } local time {of dateExpr}
the { [ long | short | abbr{ev{iated}} ] } simple date {of dateExpr}
the { [ long | short | abbr{ev{iated}} ] } [c time | ctime] {of dateExpr} the { [ long | short | abbr{ev{iated}} ] } [utc | zulu] time {of dateExpr}
the { [ long | short | abbr{ev{iated}} ] } military time {of dateExpr}

例:

put the basic date --> Jan 4, 2008
put the basic date of "10/2/1869" -- 1869年10月2日
put the long basic date --> January 4, 2008
put the basic time --> Jan 4, 2008 03:20 PM

例:

put the common date --> 4 Jan 2008
put the common time --> 4 Jan 2008 03:20 PM

例:

put the simple date --> 01/04
put the long simple date --> January 4

例:

put the dateitems --> "1995,10,07,17,50,22,7"
put the short dateitems --> "1995,10,07,17,50,22"
put the abbrev dateitems -- "1995,10,07,17,50,22,6,-0600"
put the long dateitems --> "1995,10,07,17,50,22,6,America/Denver"
put dateitems("May 14, 1942") -- "1942,05,14,12,00,00,5"

例:

put the international date --> 2005-10-19
put the short international date --> 2005-10
put the international time --> 2005-10-19T18:32:31-0600
put the abbrev international time --> 2005-10-19 18:32:31 -0600

例:

put the internet date --> Wed, 19 Oct 2005 18:21:47 -0600
put the short internet date --> 19 Oct 2005 18:21 -0600
put the long internet date --> Wednesday, 19 October 2005 18:21:47 -0600

例:

put the local time --> 05:42 PM -0700
put the short local time --> 05:42 PM US/Mountain
put the long local time --> 05:42:12 PM US/Mountain

例:

put the C time --> Fri Sep 17 13:38:17 2010
put the long CTime --> Friday September 17 13:39:48 2010

例:

put the UTC time --> 2022-04-11 15:18:29 +0000
put the long UTC time --> 2022-04-11 15:18:29.312 +0000
put the short Zulu time --> 15:18 +0000
put the abbrev UTC time --> 15:18:29 +0000

例:

put the military time --> 11 1518Z Apr 22
put the long military time --> 11 151829Z Apr 22
put the short military time --> 1518Z
put the abbrev military time --> 11 1518Z

これらの関数それぞれが返す値には、数字とフォーマットの両方が含まれています。テキストとして使用すると、上記のconvertコマンドのテーブルに表示される形式で自動的に表示されます。返された値は、日付/時間の計算に使用するために、数字として扱うこともできます。パラメーターなしで呼び出された場合、数値は現在の日付の正午(date関数の場合)または関数が呼び出された正確な日付と時間(time関数の場合)を表します。

dateExprが指定された場合、その式は日付および/または時間として評価され、返される値はその日付と時間(またはその日付の正午、date関数の場合)を表します。

関連する項目:

FormattedTime関数

動作: formattedTime関数は、指定したカスタムフォーマットを使用して日付/時間の値を返します。オプションで第二パラメータとしてフォーマットしたい日付/時間を指定できます。日付/時間の値が指定されていない場合、結果は現在の時間を指定したフォーマットで返します。

SenseTalkで日付/時間のフォーマットを書く方法の完全な情報については、SenseTalk Date and Time Formatsを参照してください。

構文:
the formattedTime of customFormat
formattedTime( customFormat {,dateTimeValue} )

例:

put formattedTime("Calendar for [year]") into calendarTitle

例:

put the formattedTime of "It is now day [day of year] of [year]!"

例:

put formattedTime(the timeFormat's longDate, sentDt) into dateSent

例:

put formattedTime("%Y%m%d_%H%M%S", logTime) into logFileName

関連する項目:

put the date --> "10/07/95"

MonthNamesWeekDayNames関数

**動作:**日付のフォーマット時に両方の関数を使用します:

  • monthNames関数:すべての月の名前のリストを返します。
  • weekDayNames関数:週の日の名前のリストを返します。

両方の関数は、longshortabbreviatedの形容詞を使用して呼び出すことができ、これらに変化を返します。各ケースでは、長い形式は何も形容詞を指定しないのと同じで、省略形は完全な名前ではなく3文字の略語のリストを返し、短い形は数値表現を返します。

構文:
the { [ long | short | abbr{ev{iated}} ] } monthNames
monthNames()
the { [ long | short | abbr{ev{iated}} ] } weekDayNames
UTCOffset( {aDate} )

例:

put monthNames() into monthList

例:

put the abbreviated monthNames

例:

put item dayNum of weekDayNames() into dayName

例:

put the short weekDayNames -- displays the numbers 0 to 6

関連する項目:

AvailableTimeZoneNames関数

動作: availableTimeZoneNames関数は、ローカルオペレーティングシステムが認識しているタイムゾーンの名前のリストを返します。これらの名前は、SenseTalkがタイムゾーン名が期待される日付/時間文字列の中で認識するものです。

ノート

この関数はローカルシステムからの情報に依存しているため、異なるオペレーティングシステムやOSバージョンで使用すると結果が異なる場合があります。

構文:
the availableTimeZoneNames
availableTimeZoneNames()

例:

Log the availableTimeZoneNames // Logs all time zone names known by the local operating system

例:

全てのアメリカのタイムゾーンを記録:

put the availableTimeZoneNames into tznames

repeat with each item zone of tznames
if zone contains "America"
insert zone after AmerZones
end if
end repeat
log AmerZones.archive

関連する項目:

AvailableTimeZoneAbbreviations関数

振る舞い: availableTimeZoneAbbreviations関数は、キーがタイムゾーンの省略形のプロパティリストを返します。各省略形の対応する値は、その省略形が表すタイムゾーンの名前です。省略形は、タイムゾーンの名前が期待される日付/時間文字列の中で認識されます。

ノート

availableTimeZoneAbbreviations関数はローカルオペレーティングシステムからの情報を返します。ただし、OSが認識する全てのタイムゾーンが必ずしも対応する省略形を持つわけではありません。したがって、availableTimeZoneAbbreviations関数はavailableTimeZoneNames関数で返される全てのタイムゾーンを含まないかもしれません。

構文:
the availableTimeZoneAbbreviations
availableTimeZoneAbbreviations()

例:

put availableTimeZoneAbbreviations() // Returns a property list whose keys are the recognized time zone abbreviations

例:

全てのアメリカのタイムゾーンのキーと名前を記録:

put availableTimeZoneAbbreviations() into TimeZoneAbbrev

repeat with each item x of keys(TimeZoneAbbrev)
put x & ": " & property (x) of TimeZoneAbbrev into timeZonesAmericas
If timeZonesAmericas contains "America"
log timeZonesAmericas
End If
end repeat

関連する項目:

put (expirationDate-"today") / 1day into daysRemaining

各日付/時刻値には、関連付けられた表示形式があります。また、特定のタイムゾーン(通常は日付/時刻値が作成されたローカルタイムゾーン)と関連付けられています。日付/時刻値のこれらの側面は、以下のプロパティを使用してアクセスおよび変更することができます。

Formatプロパティ

動作: 各日付/時間値には関連する表示形式があります。この形式は、値のformatプロパティを直接使用することで設定できます。値が変数に格納されている場合、形式プロパティも設定できます。

構文:
the format of dateTimeValue
dateTimeValue.format
dateTimeValue.format > dateTimeValue's format

例:

put date().format --> [mo]/[da]/[yr]

例:

put (long date).format --> [weekday], [monthName] [day], [year]

例:

set the format of dueDate to the timeFormat.InternationalDate

構文:

put the abbrev date --> "Sat, Oct 7, 1995"

convert source to formatName {and formatName}

タイムゾーンを指定する際には、公式のID名(例:"America/Los_Angeles")、タイムゾーンの略称("PDT")、または名前の一部を利用できます。スペースや特殊文字は無視します(例:"los angeles")。

構文:
the [ TimeZone | TimeZoneAbbreviation | TimeZoneOffset ] of dateTimeValue
dateTimeValue.[ TimeZone | TimeZoneAbbreviation | TimeZoneOffset ]
dateTimeValue's [ TimeZone | TimeZoneAbbreviation | TimeZoneOffset ]

例:

put date().timeZone --> America/Denver
put date().timeZoneAbbreviation --> MDT
put date()'s timeZoneOffset--> -6 hours

例:

put now into aTime // store the current time into a variable
put aTime --> 2022-04-12 17:41:58 -0600
put aTime's timeZone --> America/Denver
put aTime's timeZoneOffset --> -6 hours

set aTime's timeZoneOffset to -2 hours // change to a different time zone

set aTime.timeZoneAbbreviation to "GMT" // a different way to change the time zone
put aTime --> 2022-04-12 23:41:58 +0000

set aTime's timeZone to "athens"
put aTime.timeZone --> Europe/Athens
put aTime's timeZoneOffset --> 3 hours
put aTime --> 2022-04-13 02:41:58 +0300 (note the date change)

set aTime's timeZone to "denver" // return to the original time zone
put aTime --> 2022-04-12 17:41:58 -0600 (note the actual moment in time has never changed)

関連する項目: