1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295 |
- ' Copyright (c) 2007-2022 Bruce A Henderson
- ' All rights reserved.
- '
- ' Redistribution and use in source and binary forms, with or without
- ' modification, are permitted provided that the following conditions are met:
- ' * Redistributions of source code must retain the above copyright
- ' notice, this list of conditions and the following disclaimer.
- ' * Redistributions in binary form must reproduce the above copyright
- ' notice, this list of conditions and the following disclaimer in the
- ' documentation and/or other materials provided with the distribution.
- ' * Neither the name of the copyright holder nor the
- ' names of its contributors may be used to endorse or promote products
- ' derived from this software without specific prior written permission.
- '
- ' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- ' EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- ' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- ' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- ' DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- ' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- ' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ' ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- ' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- ' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- '
- SuperStrict
- Rem
- bbdoc: Date Time
- End Rem
- Module Boost.DateTime
- ModuleInfo "Version: 1.08"
- ModuleInfo "License: BSD"
- ModuleInfo "Copyright: Wrapper - 2007-2022 Bruce A Henderson"
- ModuleInfo "Modserver: BRL"
- ModuleInfo "History: 1.08"
- ModuleInfo "History: Refactored"
- ModuleInfo "History: 1.07"
- ModuleInfo "History: Updated to Boost 1.80"
- ModuleInfo "History: 1.06"
- ModuleInfo "History: Fixed glue bool/long usage."
- ModuleInfo "History: 1.05"
- ModuleInfo "History: Updated to Boost 1.67"
- ModuleInfo "History: 1.04"
- ModuleInfo "History: Updated to Boost 1.65.1"
- ModuleInfo "History: 1.03"
- ModuleInfo "History: Updated to boost 1.52"
- ModuleInfo "History: Added TTimeFacet, and format methods for TTime and TTimeDuration."
- ModuleInfo "History: Reworked format functionality to accept facets."
- ModuleInfo "History: Rewrote glue String handling."
- ModuleInfo "History: New BaH.BoostLocale requirement - for much improved localised date/time support."
- ModuleInfo "History: 1.02"
- ModuleInfo "History: Updated to boost 1.42"
- ModuleInfo "History: 1.01"
- ModuleInfo "History: Updated to boost 1.38"
- ModuleInfo "History: Improved exception handling."
- ModuleInfo "History: Fixed format() method for iterators."
- ModuleInfo "History: 1.00"
- ModuleInfo "History: Initial Release."
- ModuleInfo "CC_OPTS: -fexceptions"
- Import Boost.Locale
- ?Not Win32
- ModuleInfo "CC_OPTS: -DBOOST_LOCALE_NO_WINAPI_BACKEND -DBOOST_LOCALE_NO_STD_BACKEND -DBOOST_LOCALE_WITH_ICONV"
- ?Win32
- ModuleInfo "CC_OPTS: -DBOOST_LOCALE_NO_POSIX_BACKEND -DBOOST_LOCALE_NO_STD_BACKEND"
- ?macos
- Import "-liconv"
- ?
- Import "source.bmx"
- Rem
- bbdoc: The primary interface for date programming.
- about: In general, the date class is immutable once constructed although it does allow assignment
- from another date.
- End Rem
- Type TDate
- Field datePtr:Byte Ptr
- Private
- Method New(datePtr:Byte Ptr)
- Self.datePtr = datePtr
- End Method
- Public
- Method New()
- New(bmx_datetime_localday())
- End Method
- Rem
- bbdoc: Creates a new #TDate.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(1984, 4, 23)
-
- Print d.toString()
-
- Print New TDate(1990, EMonth.March, 12).toString()
- </pre>
- <a href="../examples/tdate_create.bmx">Example source</a>
- End Rem
- Method New(year:Int, month:Int, day:Int)
- New (bmx_datetime_newdate(year, month, day))
- End Method
-
- Method New(year:Int, month:EMonth, day:Int)
- New (bmx_datetime_newdate(year, Int(month), day))
- End Method
-
- Method New(year:Int, month:EMonth, day:ENthDay)
- New (bmx_datetime_newdate(year, Int(month), Int(day)))
- End Method
-
- Method New(year:Int, month:Int, day:ENthDay)
- New (bmx_datetime_newdate(year, month, Int(day)))
- End Method
-
- Rem
- bbdoc: Creates a new #TDate for the current local time.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.localDay()
-
- Print d.toString()
- </pre>
- <a href="../examples/tdate_localDay.bmx">Example source</a>
- End Rem
- Function localDay:TDate()
- Return New TDate(bmx_datetime_localday())
- End Function
-
- Rem
- bbdoc: Creates a new #TDate for the current UCT time.
- End Rem
- Function universalDay:TDate()
- Return New TDate(bmx_datetime_universalday())
- End Function
-
- Rem
- bbdoc: From delimited date string where with order year-month-day eg: 2002-1-25
- returns: A #TDate of the string entered, or Null if the date was invalid.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.fromString("2004-09-25")
-
- Print d.toString()
- </pre>
- <a href="../examples/tdate_fromString.bmx">Example source</a>
- End Rem
- Function FromString:TDate(date:String)
- Return New TDate(bmx_datetime_fromstring(date))
- End Function
-
- Rem
- bbdoc: From iso type date string where with order year-month-day eg: 20020125
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.fromUndelimitedString("19760130")
-
- Print d.toString()
- </pre>
- <a href="../examples/tdate_fromUndelimitedString.bmx">Example source</a>
- End Rem
- Function fromUndelimitedString:TDate(date:String)
- Return New TDate(bmx_datetime_fromundelimitedstring(date))
- End Function
- Rem
- bbdoc: Returns true if the date is before @when.
- End Rem
- Method isBefore:Int(when:TDate)
- Return bmx_datetime_before(datePtr, when.datePtr)
- End Method
- Rem
- bbdoc: Returns true if the date is after @when.
- End Rem
- Method isAfter:Int(when:TDate)
- Return bmx_datetime_after(datePtr, when.datePtr)
- End Method
- Rem
- bbdoc: Returns true if the two dates are equal.
- End Rem
- Method isEqual:Int(when:TDate)
- Return bmx_datetime_equals(datePtr, when.datePtr)
- End Method
- ' for sorting !
- Method compare:Int(obj:Object)
-
- If TDate(obj) Then
- If isBefore(TDate(obj)) Then Return -1
- If isEqual(TDate(obj)) Then Return 0
- Return 1
- End If
-
- Return Super.compare(obj)
- End Method
-
- Rem
- bbdoc: Returns the year part of the date.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2007, Jul, 17)
-
- Print d.year()
- </pre>
- <a href="../examples/tdate_year.bmx">Example source</a>
- End Rem
- Method year:Int()
- Return bmx_datetime_year(datePtr)
- End Method
-
- Rem
- bbdoc: Returns the month part of the date.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2007, Jul, 17)
-
- Print d.month()
- </pre>
- <a href="../examples/tdate_month.bmx">Example source</a>
- End Rem
- Method Month:Int()
- Return bmx_datetime_month(datePtr)
- End Method
-
- Rem
- bbdoc: Returns the day (of the month) part of the date.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2007, Jul, 17)
-
- Print d.day()
- </pre>
- <a href="../examples/tdate_day.bmx">Example source</a>
- End Rem
- Method day:Int()
- Return bmx_datetime_day(datePtr)
- End Method
-
- Rem
- bbdoc: Populates @year, @month and @day with the date parts.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2006, Dec, 24)
-
- Local year:Int, month:Int, day:Int
-
- d.ymd(year, month, day)
-
- Print year
- Print month
- Print day
- </pre>
- <a href="../examples/tdate_ymd.bmx">Example source</a>
- End Rem
- Method ymd(year:Int Var, month:Int Var, day:Int Var)
- bmx_datetime_ymd(datePtr, Varptr year, Varptr month, Varptr day)
- End Method
-
- Rem
- bbdoc: Get the day of the week.
- about: Sunday = 0, Monday = 1, etc.
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.localDay()
-
- Print d.dayOfWeek()
- </pre>
- <a href="../examples/tdate_dayOfWeek.bmx">Example source</a>
- End Rem
- Method dayOfWeek:Int()
- Return bmx_datetime_day_of_week(datePtr)
- End Method
-
- Rem
- bbdoc: Get the weekday as a string.
- about: This is based on the current weekday format as specified by #TDateFacet.
- End Rem
- Method WeekDay:String()
- Return bmx_weekday_to_string(dayOfWeek())
- End Method
-
- Rem
- bbdoc: Get the day of the year.
- about: Number from 1 to 366.
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.localDay()
-
- Print d.dayOfYear()
- </pre>
- <a href="../examples/tdate_dayOfYear.bmx">Example source</a>
- End Rem
- Method dayOfYear:Int()
- Return bmx_datetime_day_of_year(datePtr)
- End Method
-
- Rem
- bbdoc: Returns a #TDate object set to the last day of the calling objects current month.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.localDay()
- Local lastDay:TDate = d.lastDayOfMonth()
-
- Print lastDay.toString()
- </pre>
- <a href="../examples/tdate_lastDayOfMonth.bmx">Example source</a>
- End Rem
- Method lastDayOfMonth:TDate()
- Return New TDate(bmx_datetime_end_of_month(datePtr))
- End Method
-
- Rem
- bbdoc: Returns the ISO 8601 week number for the date.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.localDay()
-
- Print d.weekNumber()
- </pre>
- <a href="../examples/tdate_weekNumber.bmx">Example source</a>
- End Rem
- Method weekNumber:Int()
- Return bmx_datetime_week_number(datePtr)
- End Method
-
- Rem
- bbdoc: Return a #TDate adding a day offset.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.localDay()
-
- Print d.add(10).toString()
- </pre>
- <a href="../examples/tdate_add.bmx">Example source</a>
- End Rem
- Method add:TDate(days:Int)
- Return New TDate(bmx_datetime_date_add(datePtr, days))
- End Method
-
- Rem
- bbdoc: Return a #TDate by adding a day offset.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.localDay()
-
- Print d.subtract(14).toString()
- </pre>
- <a href="../examples/tdate_subtract.bmx">Example source</a>
- End Rem
- Method subtract:TDate(days:Int)
- Return New TDate(bmx_datetime_date_subtract(datePtr, days))
- End Method
-
- Rem
- bbdoc: Returns the number of days difference.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d1:TDate = New TDate(2000, Jan, 1)
- Local d2:TDate = TDate.localDay()
-
- Print d2.subtractDate(d1)
- </pre>
- <a href="../examples/tdate_subtractDate.bmx">Example source</a>
- End Rem
- Method subtractDate:Int(date:TDate)
- Return bmx_datetime_date_subdate(datePtr, date.datePtr)
- End Method
-
- Rem
- bbdoc: To YYYY-mmm-DD string where mmm 3 char month name.
- End Rem
- Method toString:String()
- Return bmx_datetime_to_string(datePtr, currentDateFacet.localePtr, currentDateFacet.facetPtr)
- End Method
- Rem
- bbdoc: To YYYY-mmm-DD string where mmm 3 char month name.
- End Rem
- Method toSimpleString:String()
- Return bmx_datetime_to_simple_string(datePtr)
- End Method
-
- Rem
- bbdoc: To YYYYMMDD where all components are integers.
- End Rem
- Method toISOString:String()
- Return bmx_datetime_to_iso_string(datePtr)
- End Method
-
- Rem
- bbdoc: To YYYY-MM-DD where all components are integers.s
- End Rem
- Method toISOExtendedString:String()
- Return bmx_datetime_to_iso_extended_string(datePtr)
- End Method
-
- Rem
- bbdoc: Returns a #TDateDayIterator for this date.
- about: @offset is the number of days moved in each forward/backward.
- End Rem
- Method dayIterator:TDateDayIterator(offset:Int = 1)
- Return New TDateDayIterator(Self, offset)
- End Method
- Rem
- bbdoc: Returns a #TDateMonthIterator for this date.
- about: @offset is the number of months moved in each forward/backward.
- End Rem
- Method monthIterator:TDateMonthIterator(offset:Int = 1)
- Return New TDateMonthIterator(Self, offset)
- End Method
- Rem
- bbdoc: Returns a #TDateYearIterator for this date.
- about: @offset is the number of years moved in each forward/backward.
- End Rem
- Method yearIterator:TDateYearIterator(offset:Int = 1)
- Return New TDateYearIterator(Self, offset)
- End Method
-
- Rem
- bbdoc: Output the date in the specified format.
- about: Formatting characters are as follows :
- <table align="center" width="90%">
- <tr><th>Format Specifier</th><th>Description</th></tr>
- <tr><td>%a</td><td>Abbreviated weekday name</td></tr>
- <tr><td>%A</td><td>Long weekday name</td></tr>
- <tr><td>%b</td><td>Abbreviated month name</td></tr>
- <tr><td>%B</td><td>Full month name</td></tr>
- <tr><td>%c</td><td>The preferred date and time representation for the current locale.</td></tr>
- <tr><td>%C</td><td>The century number (year/100) as a 2-digit integer.</td></tr>
- <tr><td>%d</td><td>Day of the month as decimal 01 to 31</td></tr>
- <tr><td>%D</td><td>Equivalent to %m/%d/%y</td></tr>
- <tr><td>%e</td><td>Like %d, the day of the month as a decimal number, but a leading zero is replaced by a
- space</td></tr>
- <tr><td>%G</td><td>This has the same format and value as %y, except that if the ISO week number belongs to
- the previous or next year, that year is used instead.</td></tr>
- <tr><td>%g</td><td>Like %G, but without century.</td></tr>
- <tr><td>%h</td><td>Equivalent to %b</td></tr>
- <tr><td>%j</td><td>Day of year as decimal from 001 to 366 for leap years, 001 - 365 for non-leap years.</td></tr>
- <tr><td>%m</td><td>Month name as a decimal 01 to 12</td></tr>
- <tr><td>%u</td><td>The day of the week as a decimal, range 1 to 7, Monday being 1.</td></tr>
- <tr><td>%U</td><td>The week number of the current year as a decimal number, range 00 to 53, starting with the
- first Sunday as the first day of week 01. In 2005, Jan 1st falls on a Saturday, so therefore it falls within
- week 00 of 2005 (week 00 spans 2004-Dec-26 to 2005-Jan-01. This also happens to be week 53 of 2004).</td></tr>
- <tr><td>%V</td><td>The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53,
- where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first
- day of the week.</td></tr>
- <tr><td>%w</td><td>Weekday as decimal number 0 to 6</td></tr>
- <tr><td>%W</td><td>Week number 00 to 53 where Monday is first day of week 1</td></tr>
- <tr><td>%x</td><td>Implementation defined date format from the locale.</td></tr>
- <tr><td>%y</td><td>Two digit year</td></tr>
- <tr><td>%Y</td><td>Four digit year</td></tr>
- <tr><td>%Y-%b-%d</td><td>Default date format</td></tr>
- <tr><td>%Y%m%d</td><td>ISO format</td></tr>
- <tr><td>%Y-%m-%d</td><td>ISO extended format</td></tr>
- </table>
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = TDate.localDay()
-
- Print d.format("This is day %d of month %m, of the year %G.")
- </pre>
- <a href="../examples/tdate_format.bmx">Example source</a>
- End Rem
- Method format:String(f:String, facet:TDateFacet = Null)
- If facet Then
- Return bmx_date_asformat(datePtr, f, facet.localePtr, facet.facetPtr)
- Else
- Return bmx_date_asformat(datePtr, f, currentDateFacet.localePtr, currentDateFacet.facetPtr)
- End If
- End Method
-
- ' deletes the date instance
- Method Delete()
- If datePtr Then
- bmx_datetime_free(datePtr)
- datePtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: #TDatePeriod provides direct representation for ranges between two dates.
- about: The range is from the begin date up to, but not including, the end date.<br>
- A period that is created with beginning and end points being equal, or with a duration of zero,
- is known as a zero length period. Zero length periods are considered invalid (it is perfectly
- legal to construct an invalid period). For these periods, the last point will always be one unit less
- that the begin point.
- End Rem
- Type TDatePeriod
-
- Field datePeriodPtr:Byte Ptr
-
- Private
- Method New()
- End Method
- Method New(datePeriodPtr:Byte Ptr)
- Self.datePeriodPtr = datePeriodPtr
- End Method
- Public
- Rem
- bbdoc: Create a period as [beginDate, endDate].
- about: If endDate is <= beginDate then the period will be invalid.
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local startDate:TDate = New TDate(2007, 1, 1)
- Local endDate:TDate = TDate.localDay()
-
- Local p:TDatePeriod = New TDatePeriod(startDate, endDate)
-
- Print p.toString()
- </pre>
- <a href="../examples/tdateperiod_create.bmx">Example source</a>
- End Rem
- Method New(beginDate:TDate, endDate:TDate)
- New(bmx_datetime_period_datedate(beginDate.datePtr, endDate.datePtr))
- End Method
-
- Rem
- bbdoc: Create a period as [beginDate, beginDate + length] where end point would be beginDate + length.
- about: If length is <= zero then the period will be defined as invalid.
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local startDate:TDate = TDate.localDay()
-
- Local p:TDatePeriod = New TDatePeriod(startDate, 150)
-
- Print p.toString()
- </pre>
- <a href="../examples/tdateperiod_createWithDays.bmx">Example source</a>
- End Rem
- Method New(beginDate:TDate, length:Int)
- New(bmx_datetime_period_withdays(beginDate.datePtr, length))
- End Method
-
- Rem
- bbdoc: Add @days to both begin and end.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local startDate:TDate = New TDate(2007, Feb, 1)
- Local endDate:TDate = New TDate(2007, Mar, 1)
-
- Local p:TDatePeriod = New TDatePeriod(startDate, endDate)
-
- Print p.toString()
-
- p.shift(15)
-
- Print p.toString()
- </pre>
- <a href="../examples/tdateperiod_shift.bmx">Example source</a>
- End Rem
- Method shift(days:Int)
- bmx_datetime_period_shift(datePeriodPtr, days)
- End Method
-
- Rem
- bbdoc: Returns first day of period.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local startDate:TDate = TDate.localDay()
-
- Local p:TDatePeriod = New TDatePeriod(startDate, 100)
-
- Print p.begin().toString()
- </pre>
- <a href="../examples/tdateperiod_begin.bmx">Example source</a>
- End Rem
- Method begin:TDate()
- Return New TDate(bmx_datetime_period_begin(datePeriodPtr))
- End Method
-
- Rem
- bbdoc: Returns the last date in the period.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local startDate:TDate = TDate.localDay()
-
- Local p:TDatePeriod = New TDatePeriod(startDate, 100)
-
- Print p.last().toString()
- </pre>
- <a href="../examples/tdateperiod_last.bmx">Example source</a>
- End Rem
- Method last:TDate()
- Return New TDate(bmx_datetime_period_last(datePeriodPtr))
- End Method
-
- Rem
- bbdoc: Returns one past the last in the period.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local startDate:TDate = TDate.localDay()
-
- Local p:TDatePeriod = New TDatePeriod(startDate, 100)
-
- Print p.periodEnd().toString()
- </pre>
- <a href="../examples/tdateperiod_periodEnd.bmx">Example source</a>
- End Rem
- Method periodEnd:TDate()
- Return New TDate(bmx_datetime_period_end(datePeriodPtr))
- End Method
-
- Rem
- bbdoc: Returns the length (number of days) in the period.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local startDate:TDate = TDate.localDay()
-
- Local p:TDatePeriod = New TDatePeriod(startDate, 100)
-
- Print p.length()
- </pre>
- <a href="../examples/tdateperiod_length.bmx">Example source</a>
- End Rem
- Method length:Int()
- Return bmx_datetime_period_length(datePeriodPtr)
- End Method
-
- Rem
- bbdoc: True if period is not well formed.
- about: eg. end less than or equal to begin.
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p1:TDatePeriod = New TDatePeriod(New TDate(2007, 2, 1), New TDate(2007, 3, 1))
- Local p2:TDatePeriod = New TDatePeriod(New TDate(2007, 2, 1), New TDate(2007, 1, 1))
-
- Print p1.isNull()
- Print p2.isNull()
- </pre>
- <a href="../examples/tdateperiod_isNull.bmx">Example source</a>
- End Rem
- Method isNull:Int()
- Return bmx_datetime_period_isnull(datePeriodPtr)
- End Method
-
- Rem
- bbdoc: True if @date is within the period.
- about: Zero length periods cannot contain any points.
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p:TDatePeriod = New TDatePeriod(New TDate(2006, 1, 1), New TDate(2007, 1, 1))
-
- Local goodDate:TDate = New TDate(2006, 6, 1)
- Local badDate:TDate = New TDate(2005, 1, 1)
-
- Print p.containsDate(goodDate)
- Print p.containsDate(badDate)
- </pre>
- <a href="../examples/tdateperiod_containsDate.bmx">Example source</a>
- End Rem
- Method containsDate:Int(date:TDate)
- Return bmx_datetime_period_containsdate(datePeriodPtr, date.datePtr)
- End Method
-
- Rem
- bbdoc: True if @period is within this period.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p:TDatePeriod = New TDatePeriod(New TDate(2006, 1, 1), New TDate(2007, 1, 1))
-
- Local pGood:TDatePeriod = New TDatePeriod(New TDate(2006, 4, 4), New TDate(2006, 5, 5))
- Local pBad:TDatePeriod = New TDatePeriod(New TDate(2006, 10, 1), New TDate(2007, 2, 1))
-
- Print p.contains(pGood)
- Print p.contains(pBad)
- </pre>
- <a href="../examples/tdateperiod_contains.bmx">Example source</a>
- End Rem
- Method contains:Int(period:TDatePeriod)
- Return bmx_datetime_period_contains(datePeriodPtr, period.datePeriodPtr)
- End Method
-
- Rem
- bbdoc: True if periods overlap.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p:TDatePeriod = New TDatePeriod(New TDate(2006, 1, 1), New TDate(2007, 1, 1))
-
- Local pGood:TDatePeriod = New TDatePeriod(New TDate(2006, 10, 1), New TDate(2007, 2, 1))
- Local pBad:TDatePeriod = New TDatePeriod(New TDate(2005, 1, 1), New TDate(2005, 12, 1))
-
- Print p.intersects(pGood)
- Print p.intersects(pBad)
- </pre>
- <a href="../examples/tdateperiod_intersects.bmx">Example source</a>
- End Rem
- Method intersects:Int(period:TDatePeriod)
- Return bmx_datetime_period_intersects(datePeriodPtr, period.datePeriodPtr)
- End Method
-
- Rem
- bbdoc: Calculates the intersection of 2 periods.
- about: Null if no intersection.
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p1:TDatePeriod = New TDatePeriod(New TDate(2006, 1, 1), New TDate(2007, 1, 1))
-
- Local p2:TDatePeriod = New TDatePeriod(New TDate(2006, 10, 1), New TDate(2007, 2, 1))
-
- Local intersection:TDatePeriod = p1.intersection(p2)
-
- If intersection Then
- Print intersection.toString()
- End If
- </pre>
- <a href="../examples/tdateperiod_intersection.bmx">Example source</a>
- End Rem
- Method intersection:TDatePeriod(period:TDatePeriod)
- Return New TDatePeriod(bmx_datetime_period_intersection(datePeriodPtr, period.datePeriodPtr))
- End Method
-
- Rem
- bbdoc: Checks if two periods are adjacent, but not overlapping.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p1:TDatePeriod = New TDatePeriod(New TDate(2006, 10, 1), New TDate(2007, 1, 1))
- Local p2:TDatePeriod = New TDatePeriod(New TDate(2006, 1, 1), New TDate(2006, 10, 1))
-
- Local p3:TDatePeriod = New TDatePeriod(New TDate(2006, 1, 1), New TDate(2006, 9, 1)) ' a gap here!
-
- Print p1.isAdjacent(p2)
- Print p1.isAdjacent(p3)
- </pre>
- <a href="../examples/tdateperiod_isAdjacent.bmx">Example source</a>
- End Rem
- Method isAdjacent:Int(period:TDatePeriod)
- Return bmx_datetime_period_adjacent(datePeriodPtr, period.datePeriodPtr)
- End Method
-
- Rem
- bbdoc: Determines if the period is after a given date.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p:TDatePeriod = New TDatePeriod(New TDate(2006, 10, 1), New TDate(2007, 1, 1))
-
- Print p.isAfter(New TDate(2000, 1, 1))
- Print p.isAfter(New TDate(2008, 1, 1))
- </pre>
- <a href="../examples/tdateperiod_isAfter.bmx">Example source</a>
- End Rem
- Method isAfter:Int(date:TDate)
- Return bmx_datetime_period_after(datePeriodPtr, date.datePtr)
- End Method
-
- Rem
- bbdoc: Determines if the period is before a given date.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p:TDatePeriod = New TDatePeriod(New TDate(2006, 10, 1), New TDate(2007, 1, 1))
-
- Print p.isBefore(New TDate(2000, 1, 1))
- Print p.isBefore(New TDate(2008, 1, 1))
- </pre>
- <a href="../examples/tdateperiod_isBefore.bmx">Example source</a>
- End Rem
- Method isBefore:Int(date:TDate)
- Return bmx_datetime_period_before(datePeriodPtr, date.datePtr)
- End Method
-
- Rem
- bbdoc: Returns union of two periods.
- about: Null if no intersection.
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p1:TDatePeriod = New TDatePeriod(New TDate(2006, 10, 1), New TDate(2007, 1, 1))
- Local p2:TDatePeriod = New TDatePeriod(New TDate(2006, 12, 1), New TDate(2007, 2, 1))
-
- Local p3:TDatePeriod = New TDatePeriod(New TDate(2006, 1, 1), New TDate(2006, 5, 1)) ' doesn't overlap !
-
-
- Local merged:TDatePeriod = p1.merge(p2)
-
- If Not merged.isNull() Then
- Print merged.toString()
- End If
-
- merged = p1.merge(p3)
-
- If merged.isNull() Then
- Print p1.toString() + " and " + p3.toString() + " do NOT overlap!"
- End If
- </pre>
- <a href="../examples/tdateperiod_merge.bmx">Example source</a>
- End Rem
- Method merge:TDatePeriod(period:TDatePeriod)
- Return New TDatePeriod(bmx_datetime_period_merge(datePeriodPtr, period.datePeriodPtr))
- End Method
-
- Rem
- bbdoc: Combines two periods and any gap between them such that begin = min(begin, period.begin) and end = max(end , period.end)
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local p1:TDatePeriod = New TDatePeriod(New TDate(2006, 1, 1), New TDate(2006, 10, 1))
- Local p2:TDatePeriod = New TDatePeriod(New TDate(2006, 12, 1), New TDate(2007, 2, 1))
-
- Local span:TDatePeriod = p1.span(p2)
-
- If Not span.isNull() Then
- Print span.toString()
- End If
- </pre>
- <a href="../examples/tdateperiod_span.bmx">Example source</a>
- End Rem
- Method span:TDatePeriod(period:TDatePeriod)
- Return New TDatePeriod(bmx_datetime_period_span(datePeriodPtr, period.datePeriodPtr))
- End Method
-
- Rem
- bbdoc: True if end is less than period.begin.
- End Rem
- Method isLess:Int(period:TDatePeriod)
- Return bmx_datetime_period_isless(datePeriodPtr, period.datePeriodPtr)
- End Method
- Rem
- bbdoc: True if begin greater than period.end
- End Rem
- Method isGreater:Int(period:TDatePeriod)
- Return bmx_datetime_period_isgreater(datePeriodPtr, period.datePeriodPtr)
- End Method
- Rem
- bbdoc: True if periods are the same.
- End Rem
- Method isEqual:Int(period:TDatePeriod)
- Return bmx_datetime_period_isequal(datePeriodPtr, period.datePeriodPtr)
- End Method
- ' for sorting !
- Method compare:Int(obj:Object)
-
- If TDatePeriod(obj) Then
- If isLess(TDatePeriod(obj)) Then Return -1
- If isEqual(TDatePeriod(obj)) Then Return 0
- Return 1
- End If
-
- Return Super.compare(obj)
- End Method
- Rem
- bbdoc: To [YYYY-mmm-DD/YYYY-mmm-DD] string where mmm is 3 char month name.
- End Rem
- Method toString:String()
- Return bmx_datetime_period_to_string(datePeriodPtr)
- End Method
-
- Method Delete()
- If datePeriodPtr Then
- bmx_datetime_period_free(datePeriodPtr)
- datePeriodPtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: Base type for date iterators.
- about: The methods #forward and #backward will move along the time-line based on the size of the offset
- as defined when the iterator is created.
- See #TDateDayIterator, #TDateMonthIterator and #TDateYearIterator for implementations.
- End Rem
- Type TDateIterator Extends TDate Abstract
- Rem
- bbdoc: Move date forward one step.
- End Rem
- Method forward()
- bmx_datetime_iter_forward(datePtr)
- End Method
-
- Rem
- bbdoc: Move date backward one step.
- End Rem
- Method backward()
- bmx_datetime_iter_backward(datePtr)
- End Method
- ' following methods are overriden.... it's a tad messy, but it was the only way it would work.
- Method isBefore:Int(when:TDate)
- Return bmx_datetime_iter_before(datePtr, when.datePtr)
- End Method
- Method isAfter:Int(when:TDate)
- Return bmx_datetime_iter_after(datePtr, when.datePtr)
- End Method
- Method isEqual:Int(when:TDate)
- Return bmx_datetime_iter_equals(datePtr, when.datePtr)
- End Method
- Method year:Int()
- Return bmx_datetime_iter_year(datePtr)
- End Method
-
- Method Month:Int()
- Return bmx_datetime_iter_month(datePtr)
- End Method
-
- Method day:Int()
- Return bmx_datetime_iter_day(datePtr)
- End Method
-
- Method ymd(year:Int Var, month:Int Var, day:Int Var)
- bmx_datetime_iter_ymd(datePtr,Varptr year,Varptr month,Varptr day)
- End Method
-
- Method dayOfWeek:Int()
- Return bmx_datetime_iter_day_of_week(datePtr)
- End Method
-
- Method dayOfYear:Int()
- Return bmx_datetime_iter_day_of_year(datePtr)
- End Method
-
- Method lastDayOfMonth:TDate()
- Return New TDate(bmx_datetime_iter_end_of_month(datePtr))
- End Method
-
- Method weekNumber:Int()
- Return bmx_datetime_iter_week_number(datePtr)
- End Method
- Method add:TDate(duration:Int)
- Return New TDate(bmx_datetime_iter_date_add(datePtr, duration))
- End Method
-
- Method subtract:TDate(duration:Int)
- Return New TDate(bmx_datetime_iter_date_subtract(datePtr, duration))
- End Method
-
- Method subtractDate:Int(date:TDate)
- Return bmx_datetime_iter_date_subdate(datePtr, date.datePtr)
- End Method
-
- Method toString:String()
- Return bmx_datetime_iter_to_string(datePtr, currentDateFacet.localePtr, currentDateFacet.facetPtr)
- End Method
-
- Method toISOString:String()
- Return bmx_datetime_iter_to_iso_string(datePtr)
- End Method
-
- Method toISOExtendedString:String()
- Return bmx_datetime_iter_to_iso_extended_string(datePtr)
- End Method
- Method format:String(f:String, facet:TDateFacet = Null)
- If facet Then
- Return bmx_datetime_iter_asformat(datePtr, f, facet.localePtr, facet.facetPtr)
- Else
- Return bmx_datetime_iter_asformat(datePtr, f, currentDateFacet.localePtr, currentDateFacet.facetPtr)
- End If
- End Method
- Method Delete()
- If datePtr Then
- bmx_datetime_iter_free(datePtr)
- datePtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: A #TDateIterator for stepping over days.
- End Rem
- Type TDateDayIterator Extends TDateIterator
- Rem
- bbdoc: Creates a new #TDateDayIterator from @date for the step size of @offset days.
- End Rem
- Method New(date:TDate, offset:Int = 1)
- datePtr = bmx_datetime_dayiter(date.datePtr, offset)
- End Method
- End Type
- Rem
- bbdoc: A #TDateIterator for stepping over months.
- End Rem
- Type TDateMonthIterator Extends TDateIterator
- Rem
- bbdoc: Creates a new #TDateMonthIterator from @date for the step size of @offset months.
- End Rem
- Method New(date:TDate, offset:Int = 1)
- datePtr = bmx_datetime_monthiter(date.datePtr, offset)
- End Method
- End Type
- Rem
- bbdoc: A #TDateIterator for stepping over years.
- End Rem
- Type TDateYearIterator Extends TDateIterator
- Rem
- bbdoc: Creates a new #TDateYearIterator from @date for the step size of @offset years.
- End Rem
- Method New(date:TDate, offset:Int = 1)
- datePtr = bmx_datetime_yeariter(date.datePtr, offset)
- End Method
- End Type
- Rem
- bbdoc: #TTime is the primary interface for time point manipulation.
- End Rem
- Type TTime
- Field ptimePtr:Byte Ptr
- Private
- Method New(ptimePtr:Byte Ptr)
- Self.ptimePtr = ptimePtr
- End Method
- Public
- Rem
- bbdoc: Get the local time, second level resolution, based on the time zone settings of the computer.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local t:TTime = New TTime()
-
- Print t.toString()
- </pre>
- <a href="../examples/ttime_createLocal.bmx">Example source</a>
- End Rem
- Method New()
- New(bmx_ptime_local_new())
- End Method
- Rem
- bbdoc: Constructs a new #TTime from a date and offset.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2002, Jan, 1)
- Local t:TTime = New TTime(d, TDHours(14))
-
- Print t.toString()
- </pre>
- <a href="../examples/ttime_create.bmx">Example source</a>
- End Rem
- Method New(date:TDate, offset:TTimeDuration)
- New(bmx_ptime_new(date.datePtr, offset.durationPtr))
- End Method
-
- Rem
- bbdoc: Get the UTC time.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local t:TTime = New TTimeUniversal()
-
- Print t.toString()
- </pre>
- <a href="../examples/ttime_createUniversal.bmx">Example source</a>
- End Rem
- Function Universal:TTime()
- Return New TTime(bmx_ptime_universal_new())
- End Function
-
- Rem
- bbdoc: Get the local time using a sub second resolution clock.
- about: On Unix systems this is implemented using <tt>GetTimeOfDay</tt>.
- On most Win32 platforms it is implemented using <tt>ftime</tt>. Win32 systems often do not achieve
- microsecond resolution via this API. If higher resolution is critical to your application
- test your platform to see the achieved resolution.
- End Rem
- Function LocalMS:TTime()
- Return New TTime(bmx_ptime_local_microsecond_new())
- End Function
-
- Rem
- bbdoc: Get the UTC time using a sub second resolution clock.
- about: On Unix systems this is implemented using <tt>GetTimeOfDay</tt>. On most Win32 platforms it is
- implemented using <tt>ftime</tt>. Win32 systems often do not achieve microsecond resolution via this API.
- If higher resolution is critical to your application test your platform to see the achieved resolution.
- End Rem
- Function UniversalMS:TTime()
- Return New TTime(bmx_ptime_universal_microsecond_new())
- End Function
-
- Rem
- bbdoc: Converts a #FileTime value to a #TTime.
- about: This value is the number of seconds from 1-Jan-1970.<br>
- #FileTime returns the time at UTC, so you will need to apply your local offset to get
- the correct local system time.
- End Rem
- Function FromFileTime:TTime(time:Int)
- ' since the "proper" call didn't work, we do what it does internally, and add seconds to base date!
- Return New TTime(New TDate(1970, 1, 1), TDSeconds(time))
- End Function
-
- Rem
- bbdoc: Converts a time_t struct to a #TTime.
- End Rem
- Function FromTimeT:TTime(time:Byte Ptr)
- ' since the "proper" call didn't work, we construct the date + time from the struct ourselves!
- Local tm:Int Ptr = Int Ptr(time)
- Return New TTime(New TDate(tm[5] + 1900, tm[4] + 1, tm[3]), TDHours(tm[2]).add(TDMinutes(tm[1])).add(TDSeconds(tm[0])))
- End Function
-
- Rem
- bbdoc: Get the date part of a time.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2002, Jan, 10)
- Local t:TTime = New TTime(d, TDHours(1))
- Print t.date().toString()
- </pre>
- <a href="../examples/ttime_date.bmx">Example source</a>
- End Rem
- Method date:TDate()
- Return New TDate(bmx_ptime_date(ptimePtr))
- End Method
-
- Rem
- bbdoc: Get the time offset in the day.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2002, Jan, 10)
- Local t:TTime = New TTime(d, TDHours(1))
- Print t.timeOfDay().toString()
- </pre>
- <a href="../examples/ttime_timeOfDay.bmx">Example source</a>
- End Rem
- Method timeOfDay:TTimeDuration()
- Return New TTimeDuration(bmx_ptime_time_of_day(ptimePtr))
- End Method
-
- Rem
- bbdoc: To YYYY-mmm-DD HH:MM:SS.fffffffff string where mmm 3 char month name.
- about: Fractional seconds only included if non-zero.
- End Rem
- Method toString:String()
- Return bmx_ptime_to_string(ptimePtr, currentDateFacet.localePtr, currentDateFacet.facetPtr)
- End Method
-
- Rem
- bbdoc: Convert to form YYYYMMDDTHHMMSS,fffffffff where T is the date-time separator.
- End Rem
- Method toISOString:String()
- Return bmx_ptime_to_iso_string(ptimePtr)
- End Method
-
- Rem
- bbdoc: Convert to form YYYY-MM-DDTHH:MM:SS,fffffffff where T is the date-time separator.
- End Rem
- Method toISOExtendedString:String()
- Return bmx_ptime_to_iso_extended_string(ptimePtr)
- End Method
-
- Rem
- bbdoc: Adds @days to time, returning a new #TTime.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2002, Jan, 1)
- Local t:TTime = New TTime(d, TDMinutes(5))
-
- Local t2:TTime = t.addDays(1)
-
- Print t.toString()
- Print t2.toString()
- </pre>
- <a href="../examples/ttime_addDays.bmx">Example source</a>
- End Rem
- Method addDays:TTime(days:Int)
- Return New TTime(bmx_ptime_add_days(ptimePtr, days))
- End Method
-
- Rem
- bbdoc: Subtracts @days from time, returning a new #TTime.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2002, Jan, 1)
- Local t:TTime = New TTime(d, TDMinutes(5))
-
- Local t2:TTime = t.subtractDays(1)
-
- Print t.toString()
- Print t2.toString()
- </pre>
- <a href="../examples/ttime_subtractDays.bmx">Example source</a>
- End Rem
- Method subtractDays:TTime(days:Int)
- Return New TTime(bmx_ptime_subtract_days(ptimePtr, days))
- End Method
-
- Rem
- bbdoc: Adds @duration to the time, returning a new #TTime.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2002, Jan, 1)
- Local t:TTime = New TTime(d, TDMinutes(5))
-
- Local t2:TTime = t.addDuration(TDHours(1).add(TDMinutes(2)))
-
- Print t.toString()
- Print t2.toString()
- </pre>
- <a href="../examples/ttime_addDuration.bmx">Example source</a>
- End Rem
- Method addDuration:TTime(duration:TTimeDuration)
- Return New TTime(bmx_ptime_add_duration(ptimePtr, duration.durationPtr))
- End Method
- Rem
- bbdoc: Subtracts @duration from the time, returning a new #TTime.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2002, Jan, 1)
- Local t:TTime = New TTime(d, TDMinutes(5))
-
- Local t2:TTime = t.subtractDuration(TDMinutes(2))
-
- Print t.toString()
- Print t2.toString()
- </pre>
- <a href="../examples/ttime_subtractDuration.bmx">Example source</a>
- End Rem
- Method subtractDuration:TTime(duration:TTimeDuration)
- Return New TTime(bmx_ptime_subtract_duration(ptimePtr, duration.durationPtr))
- End Method
- Rem
- bbdoc: Subtracts @time from the time, returning a #TTimeDuration
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local d:TDate = New TDate(2002, Jan, 1)
- Local t1:TTime = New TTime(d, TDMinutes(5))
- Local t2:TTime = New TTime(d, TDMinutes(2))
-
- Print t2.subtract(t1).toString() ' negative result
- </pre>
- <a href="../examples/ttime_subtract.bmx">Example source</a>
- End Rem
- Method subtract:TTimeDuration(time:TTime)
- Return New TTimeDuration(bmx_ptime_subtract(ptimePtr, time.ptimePtr))
- End Method
- Rem
- bbdoc: True if this time is less than the parameter.
- End Rem
- Method isLess:Int(time:TTime)
- Return bmx_ptime_less(ptimePtr, time.ptimePtr)
- End Method
- Rem
- bbdoc: True if this time is greater than the parameter.
- End Rem
- Method isGreater:Int(time:TTime)
- Return bmx_ptime_greater(ptimePtr, time.ptimePtr)
- End Method
- Rem
- bbdoc: True if the two times are equal.
- End Rem
- Method isEqual:Int(time:TTime)
- Return bmx_ptime_equal(ptimePtr, time.ptimePtr)
- End Method
- Rem
- bbdoc:
- End Rem
- Method format:String(f:String, facet:TTimeFacet = Null)
- If facet Then
- Return bmx_ptime_asformat(ptimePtr, f, facet.localePtr, facet.facetPtr)
- Else
- Return bmx_ptime_asformat(ptimePtr, f, currentTimeFacet.localePtr, currentTimeFacet.facetPtr)
- End If
- End Method
- ' for sorting !
- Method compare:Int(obj:Object)
-
- If TTime(obj) Then
- If isLess(TTime(obj)) Then Return -1
- If isEqual(TTime(obj)) Then Return 0
- Return 1
- End If
-
- Return Super.compare(obj)
- End Method
-
- Method Delete()
- If ptimePtr Then
- bmx_ptime_free(ptimePtr)
- ptimePtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: Represents a length of time.
- End Rem
- Type TTimeDuration
- Field durationPtr:Byte Ptr
-
- Private
- Method New()
- End Method
- Method New(durationPtr:Byte Ptr)
- Self.durationPtr = durationPtr
- End Method
- Public
- Rem
- bbdoc: Creates a new #TTimeDuration from the counts.
- about: The @fractions parameter is a number of units and is therefore affected by the resolution
- the application is compiled with. If the @fractions argument exceeds the limit of the compiled
- precision, the excess value will be "carried over" into the seconds field.<br>
- Ths following is a technique using #TicksPerSecond for creating a resolution independent
- fractions count :
- <pre>
- Local numberOfTenths:Int = 5
- ' create a resolution independent count -- divide by 10 since there are 10 tenths in a second.
- Local count:Int = numberOfTenths * (TicksPerSecond() / 10)
-
- Local duration:TTimeDuration = New TTimeDuration(1, 2, 3, count) ' 01:02:03.5 - no matter the resolution settings
- </pre>
- End Rem
- Method New(hours:Int = 0, minutes:Int = 0, seconds:Int = 0, fractions:Int = 0)
- New(bmx_time_duration(hours, minutes, seconds, fractions))
- End Method
-
- Rem
- bbdoc: Creates a new #TTimeDuration for the number of hours.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local td:TTimeDuration = TTimeDuration.Hour(10)
-
- Print td.toString()
- </pre>
- <a href="../examples/ttimeduration_hour.bmx">Example source</a>
- End Rem
- Function Hour:TTimeDuration(hours:Int)
- Return New TTimeDuration(bmx_time_duration_new_hours(hours))
- End Function
- Rem
- bbdoc: Creates a new #TTimeDuration for the number of minutes.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local td:TTimeDuration = TTimeDuration.Minute(7)
-
- Print td.toString()
- </pre>
- <a href="../examples/ttimeduration_minute.bmx">Example source</a>
- End Rem
- Function Minute:TTimeDuration(minutes:Int)
- Return New TTimeDuration(bmx_time_duration_new_minutes(minutes))
- End Function
- Rem
- bbdoc: Creates a new #TTimeDuration for the number of seconds.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local td:TTimeDuration = TTimeDuration.Second(45)
-
- Print td.toString()
- </pre>
- <a href="../examples/ttimeduration_second.bmx">Example source</a>
- End Rem
- Function Second:TTimeDuration(seconds:Int)
- Return New TTimeDuration(bmx_time_duration_new_seconds(seconds))
- End Function
- Rem
- bbdoc: Creates a new #TTimeDuration for the number of milliseconds.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local td:TTimeDuration = TTimeDuration.Millisecond(180)
-
- Print td.toString()
- </pre>
- <a href="../examples/ttimeduration_millisecond.bmx">Example source</a>
- End Rem
- Function Millisecond:TTimeDuration(milliseconds:Int)
- Return New TTimeDuration(bmx_time_duration_new_milliseconds(milliseconds))
- End Function
-
- Rem
- bbdoc: Get the number of normalized hours.
- End Rem
- Method hours:Int()
- Return bmx_time_duration_hours(durationPtr)
- End Method
- Rem
- bbdoc: Get the number of minutes normalized +/-(0..59).
- End Rem
- Method minutes:Int()
- Return bmx_time_duration_minutes(durationPtr)
- End Method
- Rem
- bbdoc: Get the normalized number of second +/-(0..59).
- End Rem
- Method seconds:Int()
- Return bmx_time_duration_seconds(durationPtr)
- End Method
- Rem
- bbdoc: Get the total number of seconds truncating any fractional seconds.
- End Rem
- Method totalSeconds:Int()
- Return bmx_time_duration_total_seconds(durationPtr)
- End Method
-
- Rem
- bbdoc: Get the total number of milliseconds truncating any remaining digits.
- End Rem
- Method totalMilliseconds:Int()
- Return bmx_time_duration_total_milliseconds(durationPtr)
- End Method
-
- Rem
- bbdoc: Get the number of fractional seconds.
- End Rem
- Method fractionalSeconds:Int()
- Return bmx_time_duration_fractional_seconds(durationPtr)
- End Method
-
- Rem
- bbdoc: True if duration is negative.
- End Rem
- Method isNegative:Int()
- Return bmx_time_duration_is_negative(durationPtr)
- End Method
-
- Rem
- bbdoc: Generate a new duration with the sign inverted.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local td:TTimeDuration = TDHours(12)
-
- Print td.toString()
- Print td.invertSign().toString()
- </pre>
- <a href="../examples/ttimeduration_invertSign.bmx">Example source</a>
- End Rem
- Method invertSign:TTimeDuration()
- Return New TTimeDuration(bmx_time_duration_invert_sign(durationPtr))
- End Method
-
- Rem
- bbdoc: To HH:MM:SS.fffffffff where fff is fractional seconds that are only included if non-zero.
- End Rem
- Method toString:String()
- Return bmx_time_duration_to_string(durationPtr)
- End Method
-
- Rem
- bbdoc: Converts to a string in the form HHMMSS,fffffffff.
- End Rem
- Method toISOString:String()
- Return bmx_time_duration_to_iso_string(durationPtr)
- End Method
-
- Rem
- bbdoc: Adds @duration to this duration, returning the result in a new #TTimeDuration
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local td:TTimeDuration = TDHours(12).add(TDMinutes(35)).add(TDSeconds(12))
-
- Print td.toString()
- </pre>
- <a href="../examples/ttimeduration_add.bmx">Example source</a>
- End Rem
- Method add:TTimeDuration(duration:TTimeDuration)
- Return New TTimeDuration(bmx_time_duration_add(durationPtr, duration.durationPtr))
- End Method
-
- Rem
- bbdoc: Subtracts @duration from this duration, returning the result in a new #TTimeDuration
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local td1:TTimeDuration = New TTimeDuration(12, 30, 20)
- Local td2:TTimeDuration = New TTimeDuration(1, 30, 20)
-
- Print td1.subtract(td2).toString()
- </pre>
- <a href="../examples/ttimeduration_subtract.bmx">Example source</a>
- End Rem
- Method subtract:TTimeDuration(duration:TTimeDuration)
- Return New TTimeDuration(bmx_time_duration_subtract(durationPtr, duration.durationPtr))
- End Method
-
- Rem
- bbdoc: Divides the length of the duration by @value.
- about: Discards any remainder.
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local td:TTimeDuration = New TTimeDuration(18, 30) ' 18 hours and 30 mins
-
- Print td.divide(2).toString() ' 9 hours and 15 mins
- </pre>
- <a href="../examples/ttimeduration_divide.bmx">Example source</a>
- End Rem
- Method divide:TTimeDuration(value:Int)
- Return New TTimeDuration(bmx_time_duration_divide(durationPtr, value))
- End Method
-
- Rem
- bbdoc: Multiplies the length of the duration by @value.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local td:TTimeDuration = New TTimeDuration(4, 10, 6)
-
- Print td.multiply(3).toString()
- </pre>
- <a href="../examples/ttimeduration_multiply.bmx">Example source</a>
- End Rem
- Method multiply:TTimeDuration(value:Int)
- Return New TTimeDuration(bmx_time_duration_multiply(durationPtr, value))
- End Method
-
- Rem
- bbdoc: True if this duration is less than the parameter.
- End Rem
- Method isLess:Int(duration:TTimeDuration)
- Return bmx_time_duration_less(durationPtr, duration.durationPtr)
- End Method
-
- Rem
- bbdoc: True if this duration is greater than the parameter.
- End Rem
- Method isGreater:Int(duration:TTimeDuration)
- Return bmx_time_duration_greater(durationPtr, duration.durationPtr)
- End Method
-
- Rem
- bbdoc: True if the durations are equal.
- End Rem
- Method isEqual:Int(duration:TTimeDuration)
- Return bmx_time_duration_equal(durationPtr, duration.durationPtr)
- End Method
- Rem
- bbdoc:
- End Rem
- Method format:String(f:String, facet:TTimeFacet = Null)
- If facet Then
- Return bmx_time_duration_asformat(durationPtr, f, facet.localePtr, facet.facetPtr)
- Else
- Return bmx_time_duration_asformat(durationPtr, f, currentTimeFacet.localePtr, currentTimeFacet.facetPtr)
- End If
- End Method
- ' for sorting !
- Method compare:Int(obj:Object)
-
- If TTimeDuration(obj) Then
- If isLess(TTimeDuration(obj)) Then Return -1
- If isEqual(TTimeDuration(obj)) Then Return 0
- Return 1
- End If
-
- Return Super.compare(obj)
- End Method
-
- Method Delete()
- If durationPtr Then
- bmx_time_duration_free(durationPtr)
- durationPtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: #TimePeriod provides direct representation for ranges between two times.
- about: Periods provide the ability to simplify some types of calculations by simplifying the
- conditional logic of the program.<br>
- A period that is created with beginning and end points being equal, or with a duration of zero,
- is known as a zero length period. Zero length periods are considered invalid (it is perfectly legal to
- construct an invalid period). For these periods, the last point will always be one unit less that the
- begin point.
- End Rem
- Type TTimePeriod
- Field timePeriodPtr:Byte Ptr
-
- Private
- Method New()
- End Method
- Method New(timePeriodPtr:Byte Ptr)
- Self.timePeriodPtr = timePeriodPtr
- End Method
- Public
- Rem
- bbdoc: Create a period as [begin, end).
- about: If end is <= begin then the period will be defined as invalid.
- End Rem
- Method New(beginTime:TTime, endTime:TTime)
- New(bmx_time_period_timetime(beginTime.ptimePtr, endTime.ptimePtr))
- End Method
-
- Rem
- bbdoc: Create a period as [begin, begin + duration) where end would be begin + duration.
- about: If duration is <= zero then the period will be defined as invalid.
- End Rem
- Method New(beginTime:TTime, duration:TTimeDuration)
- New(bmx_time_period_withduration(beginTime.ptimePtr, duration.durationPtr))
- End Method
- Rem
- bbdoc: Add @duration to both begin and end.
- End Rem
- Method shift(duration:TTimeDuration)
- bmx_time_period_shift(timePeriodPtr, duration.durationPtr)
- End Method
- Rem
- bbdoc: Return first time of period.
- End Rem
- Method begin:TTime()
- Return New TTime(bmx_time_period_begin(timePeriodPtr))
- End Method
-
- Rem
- bbdoc: Return last time in the period
- End Rem
- Method last:TTime()
- Return New TTime(bmx_time_period_last(timePeriodPtr))
- End Method
-
- Rem
- bbdoc: Return one past the last in period
- End Rem
- Method periodEnd:TTime()
- Return New TTime(bmx_time_period_end(timePeriodPtr))
- End Method
-
- Rem
- bbdoc: Return the length of the time period.
- End Rem
- Method length:TTimeDuration()
- Return New TTimeDuration(bmx_time_period_length(timePeriodPtr))
- End Method
-
- Rem
- bbdoc: True if period is not well formed.
- about: eg. end is less than or equal to begin.
- End Rem
- Method isNull:Int()
- Return bmx_time_period_is_null(timePeriodPtr)
- End Method
-
- Rem
- bbdoc: True if @time is within the period.
- about: Zero length periods cannot contain any points.
- End Rem
- Method contains:Int(time:TTime)
- Return bmx_time_period_contains(timePeriodPtr, time.ptimePtr)
- End Method
-
- Rem
- bbdoc: True if @period is within the period
- End Rem
- Method containsPeriod:Int(period:TTimePeriod)
- Return bmx_time_period_containsPeriod(timePeriodPtr, period.timePeriodPtr)
- End Method
-
- Rem
- bbdoc: True if periods overlap.
- End Rem
- Method intersects:Int(period:TTimePeriod)
- Return bmx_time_period_intersects(timePeriodPtr, period.timePeriodPtr)
- End Method
-
- Rem
- bbdoc: Calculate the intersection of 2 periods.
- about: Null if no intersection.
- End Rem
- Method intersection:TTimePeriod(period:TTimePeriod)
- Return New TTimePeriod(bmx_time_period_intersection(timePeriodPtr, period.timePeriodPtr))
- End Method
-
- Rem
- bbdoc: Returns union of two periods.
- about: Null if no intersection.
- End Rem
- Method merge:TTimePeriod(period:TTimePeriod)
- Return New TTimePeriod(bmx_time_period_merge(timePeriodPtr, period.timePeriodPtr))
- End Method
-
- Rem
- bbdoc: Combines two periods and any gap between them such that begin = min(p1.begin, p2.begin) and end = max(p1.end , p2.end).
- End Rem
- Method span:TTimePeriod(period:TTimePeriod)
- Return New TTimePeriod(bmx_time_period_span(timePeriodPtr, period.timePeriodPtr))
- End Method
-
- Rem
- bbdoc: To [YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff] string where mmm is 3 char month name.
- End Rem
- Method toString:String()
- Return bmx_time_period_to_simple_string(timePeriodPtr)
- End Method
- Rem
- bbdoc: True if end is less than period.begin.
- End Rem
- Method isLess:Int(period:TTimePeriod)
- Return bmx_time_period_isless(timePeriodPtr, period.timePeriodPtr)
- End Method
- Rem
- bbdoc: True if begin greater than period.end
- End Rem
- Method isGreater:Int(period:TTimePeriod)
- Return bmx_time_period_isgreater(timePeriodPtr, period.timePeriodPtr)
- End Method
- Rem
- bbdoc: True if periods are the same.
- End Rem
- Method isEqual:Int(period:TTimePeriod)
- Return bmx_time_period_isequal(timePeriodPtr, period.timePeriodPtr)
- End Method
- ' for sorting !
- Method compare:Int(obj:Object)
-
- If TTimePeriod(obj) Then
- If isLess(TTimePeriod(obj)) Then Return -1
- If isEqual(TTimePeriod(obj)) Then Return 0
- Return 1
- End If
-
- Return Super.compare(obj)
- End Method
- Method Delete()
- If timePeriodPtr Then
- bmx_time_period_free(timePeriodPtr)
- timePeriodPtr = Null
- End If
- End Method
- End Type
- Rem
- bbdoc: The Time Zone Database (#TTZDatabase) is a store of time zone information.
- about: The specifications for many time zones (377 at this time) are provided.
- These specifications are based on data found in the
- <a href="http://www.twinsun.com/tz/tz-link.htm">zoneinfo database</a>. The specifications are stored in
- the file: <tt>data/date_time_zonespec.csv</tt>
- End Rem
- Type TTZDatabase
- Field tzDatabasePtr:Byte Ptr
-
- Private
- Method New(tzDatabasePtr:Byte Ptr)
- Self.tzDatabasePtr = tzDatabasePtr
- End Method
- Public
- Rem
- bbdoc: Creates an empty #TTZDatabase.
- End Rem
- Method New()
- New(bmx_tz_database())
- End Method
-
- Rem
- bbdoc: Creates and populates a #TTZDatabase with time zone records found in the zone spec file.
- End Rem
- Function LoadFromFile:TTZDatabase(filename:String)
- Return New TTZDatabase(bmx_tz_load_from_file(filename))
- End Function
-
- Rem
- bbdoc: Adds a time zone, to the database.
- about: @id is the region name for this zone (e.g. "America/Phoenix").
- End Rem
- Method addRecord(id:String, zone:TTimeZone)
- bmx_tz_database_add_record(tzDatabasePtr, id, zone.timeZonePtr)
- End Method
-
- Rem
- bbdoc: Returns a time zone that matches the region listed in the data file.
- returns: a #TTimeZone or Null if not found.
- End Rem
- Method timeZoneFromRegion:TTimeZone(id:String)
- Return New TTimeZone(bmx_tz_time_zone_from_region(tzDatabasePtr, id))
- End Method
-
- Rem
- bbdoc: Returns an array of strings that holds all the region ID strings from the database.
- End Rem
- Method regionList:String[]()
- Return bmx_tz_database_region_list(tzDatabasePtr)
- End Method
-
- Method Delete()
- If tzDatabasePtr Then
- bmx_tz_database_free(tzDatabasePtr)
- tzDatabasePtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: A #TLocalDateTime object is a point in time and an associated time zone.
- about: The time is represented internally as UTC.
- End Rem
- Type TLocalDateTime
- Field localDateTimePtr:Byte Ptr
-
- Private
- Method New()
- End Method
- Method New(localDateTimePtr:Byte Ptr)
- Self.localDateTimePtr = localDateTimePtr
- End Method
- Public
- Method New(zone:TTimeZone)
- New(bmx_local_date_time_new_sec_clock(zone.timeZonePtr))
- End Method
- Rem
- bbdoc:
- abtou: The given time is expected to be UTC. Therefore, the given time will be adjusted
- according to the offset described in the time zone.
- End Rem
- Method New(time:TTime, zone:TTimeZone)
- New(bmx_local_date_time_new_time(time.ptimePtr, zone.timeZonePtr))
- End Method
- Rem
- bbdoc: Returns associated #TTimeZone object.
- End Rem
- Method zone:TTimeZone()
- Return New TTimeZone(bmx_local_date_time_zone(localDateTimePtr))
- End Method
-
- Rem
- bbdoc: Determines if time value is in DST for associated zone.
- End Rem
- Method isDST:Int()
- Return bmx_local_date_time_is_dst(localDateTimePtr)
- End Method
-
- Rem
- bbdoc: Converts the local time value to a UTC value.
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local pt:TTime = New TTime(New TDate(2004, Nov, 5), TDHours(10))
-
- Local zone:TTimeZone = New TTimeZone("MST-07")
-
- Local az:TLocalDateTime = TLocalDateTime.CreateFromTime(pt, zone)
-
- Print az.UTCTime().toString()
- </pre>
- <a href="../examples/tlocaldatetime_UTCTime.bmx">Example source</a>
- End Rem
- Method UTCTime:TTime()
- Return New TTime(bmx_local_date_time_utc_time(localDateTimePtr))
- End Method
-
- Rem
- bbdoc: Returns the local time for this object (Wall-clock).
- about:
- <pre>
- SuperStrict
-
- Framework Boost.DateTime
- Import BRL.StandardIO
-
- Local pt:TTime = New TTime(New TDate(2004, Nov, 5), TDHours(10))
-
- Local zone:TTimeZone = New TTimeZone("MST-07")
-
- Local az:TLocalDateTime = TLocalDateTime.CreateFromTime(pt, zone)
-
- Print az.UTCTime().toString()
- Print az.localTime().toString()
- </pre>
- <a href="../examples/tlocaldatetime_localTime.bmx">Example source</a>
- End Rem
- Method localTime:TTime()
- Return New TTime(bmx_local_date_time_local_time(localDateTimePtr))
- End Method
-
- Method toString:String()
- Return bmx_local_date_time_to_string(localDateTimePtr)
- End Method
-
- Rem
- bbdoc: True if this local date time is less than the parameter.
- End Rem
- Method isLess:Int(ldt:TLocalDateTime)
- Return bmx_local_date_time_less(localDateTimePtr, ldt.localDateTimePtr)
- End Method
- Rem
- bbdoc: True if this local date time is greater than the parameter.
- End Rem
- Method isGreater:Int(ldt:TLocalDateTime)
- Return bmx_local_date_time_greater(localDateTimePtr, ldt.localDateTimePtr)
- End Method
- Rem
- bbdoc: True if the two local date times are equal.
- End Rem
- Method isEqual:Int(ldt:TLocalDateTime)
- Return bmx_local_date_time_equal(localDateTimePtr, ldt.localDateTimePtr)
- End Method
- ' for sorting !
- Method compare:Int(obj:Object)
-
- If TLocalDateTime(obj) Then
- If isLess(TLocalDateTime(obj)) Then Return -1
- If isEqual(TLocalDateTime(obj)) Then Return 0
- Return 1
- End If
-
- Return Super.compare(obj)
- End Method
- Rem
- bbdoc: Adds @days to local date time, returning a new #TLocalDateTime.
- End Rem
- Method addDays:TLocalDateTime(days:Int)
- Return New TLocalDateTime(bmx_local_date_time_add_days(localDateTimePtr, days))
- End Method
-
- Rem
- bbdoc: Adds @months to local date time, returning a new #TLocalDateTime.
- End Rem
- Method addMonths:TLocalDateTime(months:Int)
- Return New TLocalDateTime(bmx_local_date_time_add_months(localDateTimePtr, months))
- End Method
-
- Rem
- bbdoc: Adds @years to local date time, returning a new #TLocalDateTime.
- End Rem
- Method addYears:TLocalDateTime(years:Int)
- Return New TLocalDateTime(bmx_local_date_time_add_years(localDateTimePtr, years))
- End Method
-
- Rem
- bbdoc: Subtracts @days from local date time, returning a new #TLocalDateTime.
- End Rem
- Method subtractDays:TLocalDateTime(days:Int)
- Return New TLocalDateTime(bmx_local_date_time_subtract_days(localDateTimePtr, days))
- End Method
-
- Rem
- bbdoc: Subtracts @months from local date time, returning a new #TLocalDateTime.
- End Rem
- Method subtractMonths:TLocalDateTime(months:Int)
- Return New TLocalDateTime(bmx_local_date_time_subtract_months(localDateTimePtr, months))
- End Method
-
- Rem
- bbdoc: Subtracts @years from local date time, returning a new #TLocalDateTime.
- End Rem
- Method subtractYears:TLocalDateTime(years:Int)
- Return New TLocalDateTime(bmx_local_date_time_subtract_years(localDateTimePtr, years))
- End Method
-
- Rem
- bbdoc: Adds @duration to the local date time, returning a new #TLocalDateTime.
- End Rem
- Method addDuration:TLocalDateTime(duration:TTimeDuration)
- Return New TLocalDateTime(bmx_local_date_time_add_duration(localDateTimePtr, duration.durationPtr))
- End Method
-
- Rem
- bbdoc: Subtracts @duration from the local date time, returning a new #TLocalDateTime.
- End Rem
- Method subtractDuration:TLocalDateTime(duration:TTimeDuration)
- Return New TLocalDateTime(bmx_local_date_time_subtract_duration(localDateTimePtr, duration.durationPtr))
- End Method
-
- Method Delete()
- If localDateTimePtr Then
- bmx_local_date_time_free(localDateTimePtr)
- localDateTimePtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: #TLocalTimePeriod provides direct representation for ranges between two local times.
- about: Periods provide the ability to simplify some types of calculations by simplifying the
- conditional logic of the program.
- End Rem
- Type TLocalTimePeriod
- Field localTimePeriodPtr:Byte Ptr
- Private
- Method New()
- End Method
- Method New(localTimePeriodPtr:Byte Ptr)
- Self.localTimePeriodPtr = localTimePeriodPtr
- End Method
- Public
-
- Rem
- bbdoc: Create a period as [begin, end).
- about: If end is <= begin then the period will be defined as invalid.
- End Rem
- Method New(beginTime:TLocalDateTime, endTime:TLocalDateTime)
- New(bmx_local_time_period_new(beginTime.localDateTimePtr, endTime.localDateTimePtr))
- End Method
-
- Rem
- bbdoc: Create a period as [begin, begin + duration) where end would be begin + duration.
- about: If duration is <= zero then the period will be defined as invalid.
- End Rem
- Method New(beginTime:TLocalDateTime, duration:TTimeDuration)
- New(bmx_local_time_period_new_duration(beginTime.localDateTimePtr, duration.durationPtr))
- End Method
- Rem
- bbdoc: Return first local date time of the period.
- End Rem
- Method begin:TLocalDateTime()
- Return New TLocalDateTime(bmx_local_time_period_begin(localTimePeriodPtr))
- End Method
-
- Rem
- bbdoc: Return last local date time in the period.
- End Rem
- Method last:TLocalDateTime()
- Return New TLocalDateTime(bmx_local_time_period_last(localTimePeriodPtr))
- End Method
-
- Rem
- bbdoc: Return one past the last in period.
- End Rem
- Method periodEnd:TLocalDateTime()
- Return New TLocalDateTime(bmx_local_time_period_end(localTimePeriodPtr))
- End Method
-
- Rem
- bbdoc: Return the length of the local time period.
- End Rem
- Method length:TTimeDuration()
- Return New TTimeDuration(bmx_local_time_period_length(localTimePeriodPtr))
- End Method
-
- Rem
- bbdoc: True if period is not well formed.
- about: eg. end less than or equal to begin.
- End Rem
- Method isNull:Int()
- Return bmx_local_time_period_is_null(localTimePeriodPtr)
- End Method
-
- Rem
- bbdoc: True if @time is within the period.
- about: Zero length periods cannot contain any points.
- End Rem
- Method containsTime:Int(time:TLocalDateTime)
- Return bmx_local_time_period_contains_time(localTimePeriodPtr, time.localDateTimePtr)
- End Method
-
- Rem
- bbdoc: True if @period is within the period.
- End Rem
- Method contains:Int(period:TLocalTimePeriod)
- Return bmx_local_time_period_contains(localTimePeriodPtr, period.localTimePeriodPtr)
- End Method
-
- Rem
- bbdoc: True if periods overlap.
- End Rem
- Method intersects:Int(period:TLocalTimePeriod)
- Return bmx_local_time_period_intersects(localTimePeriodPtr, period.localTimePeriodPtr)
- End Method
-
- Rem
- bbdoc: Calculate the intersection of 2 periods.
- about: Null if no intersection.
- End Rem
- Method intersection:TLocalTimePeriod(period:TLocalTimePeriod)
- Return New TLocalTimePeriod(bmx_local_time_period_intersection(localTimePeriodPtr, period.localTimePeriodPtr))
- End Method
-
- Rem
- bbdoc: Returns union of two periods.
- about: Null if no intersection.
- End Rem
- Method merge:TLocalTimePeriod(period:TLocalTimePeriod)
- Return New TLocalTimePeriod(bmx_local_time_period_merge(localTimePeriodPtr, period.localTimePeriodPtr))
- End Method
-
- Rem
- bbdoc: Combines two periods and any gap between them such that begin = min(p1.begin, p2.begin) and end = max(p1.end , p2.end).
- End Rem
- Method span:TLocalTimePeriod(period:TLocalTimePeriod)
- Return New TLocalTimePeriod(bmx_local_time_period_span(localTimePeriodPtr, period.localTimePeriodPtr))
- End Method
-
- Rem
- bbdoc: Add duration to both begin and end.
- End Rem
- Method shift(duration:TTimeDuration)
- bmx_local_time_period_shift(localTimePeriodPtr, duration.durationPtr)
- End Method
-
- Rem
- bbdoc: True if this local time period is less than the parameter.
- End Rem
- Method isLess:Int(period:TLocalTimePeriod)
- Return bmx_local_time_period_less(localTimePeriodPtr, period.localTimePeriodPtr)
- End Method
- Rem
- bbdoc: True if this local time period is greater than the parameter.
- End Rem
- Method isGreater:Int(period:TLocalTimePeriod)
- Return bmx_local_time_period_greater(localTimePeriodPtr, period.localTimePeriodPtr)
- End Method
- Rem
- bbdoc: True if the two local time periods are equal.
- about: Periods are equal if ltp1.begin = ltp2.begin and ltp1.last = ltp2.last
- End Rem
- Method isEqual:Int(period:TLocalTimePeriod)
- Return bmx_local_time_period_equal(localTimePeriodPtr, period.localTimePeriodPtr)
- End Method
- ' for sorting !
- Method compare:Int(obj:Object)
-
- If TLocalTimePeriod(obj) Then
- If isLess(TLocalTimePeriod(obj)) Then Return -1
- If isEqual(TLocalTimePeriod(obj)) Then Return 0
- Return 1
- End If
-
- Return Super.compare(obj)
- End Method
-
- Method Delete()
- If localTimePeriodPtr Then
- bmx_local_time_period_free(localTimePeriodPtr)
- localTimePeriodPtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: A posix #TTimeZone is a set of data and rules that provide information about a time zone.
- about: Information includes the offset from UTC, its name and abbreviation, as well as daylight
- savings rules.
- <p>A posix time zone is unique in that the object is created from a Posix time zone string
- (IEEE Std 1003.1). A POSIX time zone string takes the form of:
- </p>
- <pre> "std offset dst [offset],start[/time],end[/time]" (with no spaces).</pre>
- <p>'std' specifies the abbrev of the time zone. 'offset' is the offset from UTC. 'dst' specifies the
- abbrev of the time zone during daylight savings time. The second offset is how many hours changed during
- DST. 'start' and 'end' are the dates when DST goes into (and out of) effect. 'offset' takes the form of:
- </p>
- <pre> [+|-]hh[:mm[:ss]] {h=0-23, m/s=0-59}</pre>
- <p>'time' and 'offset' take the same form. 'start' and 'end' can be one of three forms:
- </p>
- <pre>
- Mm.w.d {month=1-12, week=1-5 (5 is always last), day=0-6}
- Jn {n=1-365 Feb29 is never counted}
- n {n=0-365 Feb29 is counted in leap years}
- </pre>
- <p>Exceptions will be thrown under the following conditions: </p>
- <ul type="disc">
- <li>An exception will be thrown for an invalid date spec (see
- <a href="gregorian.html#date_time.gregorian.date_class" title="Date">date class</a>).</li>
- <li>A boost::local_time::bad_offset exception will be thrown for:</li>
- <li>A DST start or end offset that is negative or more than 24 hours.</li>
- <li>A UTC zone that is greater than +12 or less than -12 hours.</li>
- <li>A boost::local_time::bad_adjustment exception will be thrown for a DST adjustment that is 24 hours or
- more (positive or negative)</li>
- </ul>
- <p>As stated above, the 'offset' and '/time' portions of the string are not required. If they are not
- given they default to 01:00 for 'offset', and 02:00 for both occurrences of '/time'.
- </p>
- <p>
- Some examples are:</p>
- <pre>
- "PST-8PDT01:00:00,M4.1.0/02:00:00,M10.1.0/02:00:00"
- "PST-8PDT,M4.1.0,M10.1.0"
- </pre>
- <p>These two are actually the same specification (defaults were used in the second string).
- This zone lies eight hours west of GMT and makes a one hour shift forward during daylight savings
- time. Daylight savings for this zone starts on the first Sunday of April at 2am, and ends
- on the first Sunday of October at 2am.
- </p>
- <pre> "MST-7"</pre>
- <p>This zone is as simple as it gets. This zone lies seven hours west of GMT and has no daylight savings.
- </p>
- <pre> "EST10EDT,M10.5.0,M3.5.0/03"</pre>
- <p>This string describes the time zone for Sydney Australia. It lies ten hours east of GMT and makes
- a one hour shift forward during daylight savings. Being located in the southern hemisphere, daylight
- savings begins on the last Sunday in October at 2am and ends on the last Sunday in March at 3am.
- </p>
- <pre>"FST+3FDT02:00,J60/00,J304/02"</pre>
- <p>This specification describes a fictitious zone that lies three hours east of GMT. It makes a two hour
- shift forward for daylight savings which begins on March 1st at midnight, and ends on October 31st at
- 2am. The 'J' designation in the start/end specs signifies that counting starts at one and February
- 29th is never counted.
- </p>
- <pre>"FST+3FDT,59,304"</pre>
- <p>This specification is significant because of the '59'. The lack of 'J' for the start and end dates,
- indicates that the Julian day-count begins at zero and ends at 365. If you do the math, you'll see
- that allows for a total of 366 days. This is fine in leap years, but in non-leap years '59' (Feb-29)
- does not exist. This will construct a valid posix_time_zone object but an exception will be thrown if
- the date of '59' is accessed in a non-leap year. Ex:
- </p>
- <pre>posix_time_zone leap_day(std::string("FST+3FDT,59,304"));
- leap_day.dst_local_start_time(2004); // ok
- leap_day.dst_local_start_time(2003); // Exception thrown
- </pre>
- End Rem
- Type TTimeZone
- Field timeZonePtr:Byte Ptr
- Private
- Method New()
- End Method
- Method New(timeZonePtr:Byte Ptr)
- Self.timeZonePtr = timeZonePtr
- End Method
- Public
-
- Rem
- bbdoc:
- End Rem
- Method New(description:String)
- New(bmx_posix_time_zone(description))
- End Method
-
- Rem
- bbdoc: Returns the daylight savings abbreviation for the represented time zone.
- End Rem
- Method DSTZoneAbbrev:String()
- Return bmx_time_zone_dst_zone_abbrev(timeZonePtr)
- End Method
- Rem
- bbdoc: Returns the standard abbreviation for the represented time zone.
- End Rem
- Method STDZoneAbbrev:String()
- Return bmx_time_zone_std_zone_abbrev(timeZonePtr)
- End Method
- Rem
- bbdoc: Returns the daylight savings name for the represented time zone.
- End Rem
- Method DSTZoneName:String()
- Return bmx_time_zone_dst_zone_name(timeZonePtr)
- End Method
- Rem
- bbdoc: Returns the standard name for the represented time zone.
- End Rem
- Method STDZoneName:String()
- Return bmx_time_zone_std_zone_name(timeZonePtr)
- End Method
-
- Rem
- bbdoc: Returns True if this time zone makes a daylight savings shift.
- End Rem
- Method hasDST:Int()
- Return bmx_time_zone_has_dst(timeZonePtr)
- End Method
-
- Rem
- bbdoc: The date and time daylight savings time begins in given year.
- End Rem
- Method DSTLocalStartTime:TTime(year:Int)
- Return New TTime(bmx_time_zone_dst_local_start_time(timeZonePtr, year))
- End Method
- Rem
- bbdoc: The date and time daylight savings time ends in given year.
- End Rem
- Method DSTLocalEndTime:TTime(year:Int)
- Return New TTime(bmx_time_zone_dst_local_end_time(timeZonePtr, year))
- End Method
-
- Rem
- bbdoc: The amount of time offset from UTC (typically in hours).
- End Rem
- Method baseUTCOffset:TTimeDuration()
- Return New TTimeDuration(bmx_time_zone_base_utc_offset(timeZonePtr))
- End Method
-
- Rem
- bbdoc: The amount of time shifted during daylight savings.
- End Rem
- Method DSTOffset:TTimeDuration()
- Return New TTimeDuration(bmx_time_zone_dst_offset(timeZonePtr))
- End Method
-
- Rem
- bbdoc: Returns a posix time zone string representation of this time zone object.
- End Rem
- Method toString:String()
- Return bmx_time_zone_to_posix_string(timeZonePtr)
- End Method
-
- Method Delete()
- If timeZonePtr Then
- bmx_time_zone_free(timeZonePtr)
- timeZonePtr = Null
- End If
- End Method
- End Type
- Rem
- bbdoc: Date Generator base type for #TLastDayOfWeekInMonth, #TFirstDayOfWeekInMonth, #TNthDayOfWeekInMonth and #TPartialDate.
- End Rem
- Type TYearBasedGenerator Abstract
- Field ybgPtr:Byte Ptr
-
- Rem
- bbdoc: Returns the date for the specified @year.
- End Rem
- Method getDate:TDate(year:Int) Abstract
-
- End Type
- Rem
- bbdoc: Date Generator for a partial date.
- End Rem
- Type TPartialDate Extends TYearBasedGenerator
-
- Private
- Method New()
- End Method
- Public
- Rem
- bbdoc: Creates a new #TPartialDate for the given day and month.
- End Rem
- Method New(day:Int, month:Int)
- ybgPtr = bmx_partial_date_new(day, month)
- End Method
-
- Method New(day:ENthDay, month:Int)
- ybgPtr = bmx_partial_date_new(Int(day), month)
- End Method
-
- Method New(day:ENthDay, month:EMonth)
- ybgPtr = bmx_partial_date_new(Int(day), Int(month))
- End Method
-
- Method New(day:Int, month:EMonth)
- ybgPtr = bmx_partial_date_new(day, Int(month))
- End Method
- Method getDate:TDate(year:Int)
- Return New TDate(bmx_partial_date_get_date(ybgPtr, year))
- End Method
- Method Delete()
- If ybgPtr Then
- bmx_partial_date_free(ybgPtr)
- ybgPtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: Date Generator for last day of the week in month.
- End Rem
- Type TLastDayOfWeekInMonth Extends TYearBasedGenerator
- Private
- Method New()
- End Method
- Public
- Rem
- bbdoc: Creates a new #TLastDayOfWeekInMonth for the given weekday and month.
- about: A weekday may be one of #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday or #EWeekday.Saturday.<br>
- Month may be one of #EMonth.January, #EMonth.February, #EMonth.March, #EMonth.April, #EMonth.May, #EMonth.June, #EMonth.July,
- #EMonth.August, #EMonth.September, #EMonth.October, #EMonth.November or #EMonth.December.
- End Rem
- Method New(weekday:Int, month:Int)
- ybgPtr = bmx_last_day_of_week_in_month_new(weekday, month)
- End Method
-
- Method New(weekday:EWeekday, month:Int)
- ybgPtr = bmx_last_day_of_week_in_month_new(Int(weekday), month)
- End Method
-
- Method New(weekday:EWeekday, month:EMonth)
- ybgPtr = bmx_last_day_of_week_in_month_new(Int(weekday), Int(month))
- End Method
-
- Method New(weekday:Int, month:EMonth)
- ybgPtr = bmx_last_day_of_week_in_month_new(weekday, Int(month))
- End Method
- Method getDate:TDate(year:Int)
- Return New TDate(bmx_last_day_of_week_in_month_get_date(ybgPtr, year))
- End Method
- Method Delete()
- If ybgPtr Then
- bmx_last_day_of_week_in_month_free(ybgPtr)
- ybgPtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: Date Generator for first day of the week in month.
- End Rem
- Type TFirstDayOfWeekInMonth Extends TYearBasedGenerator
-
- Private
- Method New()
- End Method
- Public
- Rem
- bbdoc: Creates a new #TFirstDayOfWeekInMonth for the given weekday and month.
- about: A weekday may be one of #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday or #EWeekday.Saturday.<br>
- Month may be one of #EMonth.January, #EMonth.February, #EMonth.March, #EMonth.April, #EMonth.May, #EMonth.June, #EMonth.July,
- #EMonth.August, #EMonth.September, #EMonth.October, #EMonth.November or #EMonth.December.
- End Rem
- Method New(weekday:Int, month:Int)
- ybgPtr = bmx_first_day_of_week_in_month_new(weekday, month)
- End Method
-
- Method New(weekday:EWeekday, month:Int)
- ybgPtr = bmx_first_day_of_week_in_month_new(Int(weekday), month)
- End Method
-
- Method New(weekday:EWeekday, month:EMonth)
- ybgPtr = bmx_first_day_of_week_in_month_new(Int(weekday), Int(month))
- End Method
-
- Method New(weekday:Int, month:EMonth)
- ybgPtr = bmx_first_day_of_week_in_month_new(weekday, Int(month))
- End Method
- Method getDate:TDate(year:Int)
- Return New TDate(bmx_first_day_of_week_in_month_get_date(ybgPtr, year))
- End Method
- Method Delete()
- If ybgPtr Then
- bmx_first_day_of_week_in_month_free(ybgPtr)
- ybgPtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: Date Generator for nth day of the week in month.
- about: Calculate something like first Monday of January, second Tuesday of March, Third Sunday
- of December, etc.
- End Rem
- Type TNthDayOfWeekInMonth Extends TYearBasedGenerator
-
- Private
- Method New()
- End Method
-
- Public
-
- Rem
- bbdoc: Creates a new #TNthDayOfWeekInMonth for the given nth, weekday and month.
- about: Nth may be one of #ENthDay.First, #ENthDay.Second, #ENthDay.Third, #ENthDay.Fourth, or #ENthDay.Fifth (1-5).
- A weekday may be one of #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday or #EWeekday.Saturday (0-6).<br>
- Month may be one of #EMonth.January, #EMonth.February, #EMonth.March, #EMonth.April, #EMonth.May, #EMonth.June, #EMonth.July,
- #EMonth.August, #EMonth.September, #EMonth.October, #EMonth.November or #EMonth.December (1-12).
- End Rem
- Method New(nth:Int, weekday:Int, month:Int)
- ybgPtr = bmx_nth_day_of_week_in_month_new(nth, weekday, month)
- End Method
-
- Method New(nth:ENthDay, weekday:Int, month:Int)
- ybgPtr = bmx_nth_day_of_week_in_month_new(Int(nth), weekday, month)
- End Method
-
- Method New(nth:ENthDay, weekday:EWeekday, month:Int)
- ybgPtr = bmx_nth_day_of_week_in_month_new(Int(nth), Int(weekday), month)
- End Method
-
- Method New(nth:ENthDay, weekday:EWeekday, month:EMonth)
- ybgPtr = bmx_nth_day_of_week_in_month_new(Int(nth), Int(weekday), Int(month))
- End Method
-
- Method New(nth:Int, weekday:EWeekday, month:EMonth)
- ybgPtr = bmx_nth_day_of_week_in_month_new(nth, Int(weekday), Int(month))
- End Method
-
- Method New(nth:Int, weekday:Int, month:EMonth)
- ybgPtr = bmx_nth_day_of_week_in_month_new(nth, weekday, Int(month))
- End Method
-
- Method New(nth:Int, weekday:EWeekday, month:Int)
- ybgPtr = bmx_nth_day_of_week_in_month_new(nth, Int(weekday), month)
- End Method
- Method getDate:TDate(year:Int)
- Return New TDate(bmx_nth_day_of_week_in_month_get_date(ybgPtr, year))
- End Method
- Method Delete()
- If ybgPtr Then
- bmx_nth_day_of_week_in_month_free(ybgPtr)
- ybgPtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: Date Generator for first day of the week after a date.
- about: Calculate something like First Sunday after Jan 1,2002.
- End Rem
- Type TFirstDayOfWeekAfter
- Private
- Method New()
- End Method
- Public
- Field ybgPtr:Byte Ptr
-
- Rem
- bbdoc: Creates a new #TFirstDayOfWeekAfter for the given weekday.
- about: A weekday may be one of #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday or #EWeekday.Saturday (0-6).
- End Rem
- Method New(weekday:Int)
- ybgPtr = bmx_first_day_of_week_after_new(weekday)
- End Method
-
- Method New(weekday:EWeekday)
- ybgPtr = bmx_first_day_of_week_after_new(Int(weekday))
- End Method
- Rem
- bbdoc: Returns the date for the first day after the specified @date.
- End Rem
- Method getDate:TDate(date:TDate)
- Return New TDate(bmx_first_day_of_week_after_get_date(ybgPtr, date.datePtr))
- End Method
- Method Delete()
- If ybgPtr Then
- bmx_first_day_of_week_after_free(ybgPtr)
- ybgPtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: Date Generator for first day of the week before a date.
- about: Calculate something like First Monday before Feb 1,2002
- End Rem
- Type TFirstDayOfWeekBefore
- Private
- Method New()
- End Method
- Public
- Field ybgPtr:Byte Ptr
-
- Rem
- bbdoc: Creates a new #TFirstDayOfWeekBefore for the given weekday.
- about: A weekday may be one of #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday or #EWeekday.Saturday (0-6).
- End Rem
- Method New(weekday:Int)
- ybgPtr = bmx_first_day_of_week_before_new(weekday)
- End Method
-
- Method New(weekday:EWeekday)
- ybgPtr = bmx_first_day_of_week_before_new(Int(weekday))
- End Method
- Rem
- bbdoc: Returns the date for the first day before the specified @date.
- End Rem
- Method getDate:TDate(date:TDate)
- Return New TDate(bmx_first_day_of_week_before_get_date(ybgPtr, date.datePtr))
- End Method
- Method Delete()
- If ybgPtr Then
- bmx_first_day_of_week_before_free(ybgPtr)
- ybgPtr = Null
- End If
- End Method
-
- End Type
- Rem
- bbdoc: The default date facet
- End Rem
- Global defaultDateFacet:TDateFacet = New TDateFacet()
- Rem
- bbdoc: The current date facet (for use with toString() type formatting)
- End Rem
- Global currentDateFacet:TDateFacet = defaultDateFacet
- Rem
- bbdoc: The default time facet
- End Rem
- Global defaultTimeFacet:TTimeFacet = New TTimeFacet()
- Rem
- bbdoc: The current time facet (for use with toString() type formatting)
- End Rem
- Global currentTimeFacet:TTimeFacet = defaultTimeFacet
- 'SetCurrentDateFacet(defaultDateFacet)
- 'SetCurrentTimeFacet(defaultTimeFacet)
- Type TLocaleFacet
- ?linux
- Global defaultLocale:String = "en_US"
- ?win32
- Global defaultLocale:String = "English United States"
- ?macos
- Global defaultLocale:String = "en_US"
- ?
- Field localePtr:Byte Ptr
- Field facetPtr:Byte Ptr
- Field locale:String
- Global generator:TBLGenerator
-
- Method New()
- If Not generator Then
- generator = New TBLGenerator()
- End If
- End Method
-
- End Type
- Rem
- bbdoc: The #TDateFacet enables users to have significant control over the output of dates (and other gregorian objects).
- End Rem
- Type TDateFacet Extends TLocaleFacet
- Method New()
- New(TLocaleFacet.defaultLocale)
- End Method
- Method New(locale:String)
- Self.facetPtr = bmx_datefacet_new()
- Self.localePtr = bmx_locale_new(facetPtr, generator.genPtr, locale)
- Self.locale = locale
- End Method
-
- Rem
- bbdoc: Set the format for dates.
- End Rem
- Method format(fmt:String)
- bmx_date_facet_format(facetPtr, fmt)
- End Method
-
- Rem
- bbdoc: Sets the date format to ISO.
- End Rem
- Method setISOFormat()
- bmx_date_facet_set_iso_format(facetPtr)
- End Method
-
- Rem
- bbdoc: Sets the date format to ISO Extended.
- End Rem
- Method setISOExtendedFormat()
- bmx_date_facet_set_iso_extended_format(facetPtr)
- End Method
-
- Rem
- bbdoc: Set the format for months when they are output individually.
- End Rem
- Method monthFormat(fmt:String)
- bmx_date_facet_month_format(facetPtr, fmt)
- End Method
-
- Rem
- bbdoc: Set the format for weekdays when they are output individually.
- End Rem
- Method weekdayFormat(fmt:String)
- bmx_date_facet_weekday_format(facetPtr, fmt)
- End Method
-
- Rem
- bbdoc: Replace strings used when outputting short months.
- End Rem
- Method setShortMonthNames(names:String[])
- Assert names, "short names array cannot be null"
- Assert names.length = 12, "short names array requires 12 entries"
-
- bmx_date_facet_short_month_names(facetPtr, names)
-
- End Method
- Rem
- bbdoc: Replace strings used when outputting long months.
- End Rem
- Method setLongMonthNames(names:String[])
- Assert names, "names array cannot be null"
- Assert names.length = 12, "names array requires 12 entries"
- bmx_date_facet_long_month_names(facetPtr, names)
- End Method
- Rem
- bbdoc: Replace strings used when outputting short weekdays.
- End Rem
- Method setShortWeekdayNames(names:String[])
- Assert names, "short weekday names array cannot be null"
- Assert names.length = 7, "short weekday names array requires 12 entries"
- bmx_date_facet_short_weekday_names(facetPtr, names)
- End Method
-
- Rem
- bbdoc: Replace strings used when outputting long weekdays.
- End Rem
- Method setLongWeekdayNames(names:String[])
- Assert names, "weekday names array cannot be null"
- Assert names.length = 7, "weekday names array requires 7 entries"
- bmx_date_facet_long_weekday_names(facetPtr, names)
- End Method
-
- End Type
- Type TTimeFacet Extends TDateFacet
- Method New()
- New(defaultLocale)
- End Method
- Method New(locale:String)
- Self.facetPtr = bmx_timefacet_new()
- Self.localePtr = bmx_locale_new(facetPtr, generator.genPtr, locale)
- Self.locale = locale
- End Method
-
- Rem
- bbdoc: Set the format for dates.
- End Rem
- Method format(fmt:String)
- bmx_time_facet_format(facetPtr, fmt)
- End Method
-
- Rem
- bbdoc: Sets the date format to ISO.
- End Rem
- Method setISOFormat()
- bmx_time_facet_set_iso_format(facetPtr)
- End Method
-
- Rem
- bbdoc: Sets the date format to ISO Extended.
- End Rem
- Method setISOExtendedFormat()
- bmx_time_facet_set_iso_extended_format(facetPtr)
- End Method
-
- Rem
- bbdoc: Set the format for months when they are output individually.
- End Rem
- Method monthFormat(fmt:String)
- bmx_time_facet_month_format(facetPtr, fmt)
- End Method
-
- Rem
- bbdoc: Set the format for weekdays when they are output individually.
- End Rem
- Method weekdayFormat(fmt:String)
- bmx_time_facet_weekday_format(facetPtr, fmt)
- End Method
-
- Rem
- bbdoc: Sets the time_duration format.
- about: The time duration format has the ability to display the sign of the duration.
- The '%+' flag will always display the sign. The '%-' will only display if the sign is negative. Currently the '-' and '+' characters are used to denote the sign.
- End Rem
- Method timeDurationFormat(fmt:String)
- bmx_time_facet_time_duration_format(facetPtr, fmt)
- End Method
-
- End Type
- Rem
- bbdoc: Convenience function for TTimeDuration.Hour().
- End Rem
- Function TDHours:TTimeDuration(amount:Int)
- Return TTimeDuration.Hour(amount)
- End Function
- Rem
- bbdoc: Convenience function for TTimeDuration.Minute().
- End Rem
- Function TDMinutes:TTimeDuration(amount:Int)
- Return TTimeDuration.Minute(amount)
- End Function
- Rem
- bbdoc: Convenience function for TTimeDuration.Second().
- End Rem
- Function TDSeconds:TTimeDuration(amount:Int)
- Return TTimeDuration.Second(amount)
- End Function
- Rem
- bbdoc: Sets the current date facet.
- about: This controls the appearance of date information.
- End Rem
- Function SetCurrentDateFacet(facet:TDateFacet)
- currentDateFacet = facet
- End Function
- Rem
- bbdoc: Sets the current time facet.
- about: This controls the appearance of time and time duration information.
- End Rem
- Function SetCurrentTimeFacet(facet:TTimeFacet)
- currentTimeFacet = facet
- End Function
- Rem
- bbdoc: Return the number of ticks in a second.
- about: For example, if the duration supports nanoseconds then the returned result will be 1,000,000,000 (1e+9).
- End Rem
- Function TicksPerSecond:Int()
- Return bmx_time_ticks_per_second()
- End Function
- Rem
- bbdoc: Returns the number of fractional digits the time resolution has.
- about: 9 for nano, 6 for micro, etc.
- End Rem
- Function NumFractionalDigits:Int()
- Return bmx_time_num_fractional_digits()
- End Function
- Rem
- bbdoc: Get the weekday text for the specified @weekday (0 - 6).
- about: This is based on the current weekday format as specified by #TDateFacet.<br>
- Valid weekdays include #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday, #EWeekday.Saturday (0-6).
- End Rem
- Function WeekkdayName:String(weekday:Int)
- Return bmx_weekday_to_string(weekday)
- End Function
- Function WeekkdayName:String(weekday:EWeekday)
- Return bmx_weekday_to_string(Int(weekday))
- EndFunction
- Rem
- bbdoc: Get the month text for the specified @month (1 - 12).
- about: This is based on the current month format as specified by #TDateFacet.
- End Rem
- Function MonthName:String(month:Int)
- Return bmx_month_to_string(month)
- End Function
- Function MonthName:String(month:EMonth)
- Return bmx_month_to_string(Int(month))
- End Function
- Rem
- bbdoc: Calculates the number of days from given date until given @weekday.
- about: Valid weekdays include #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday, #EWeekday.Saturday (0-6).
- End Rem
- Function DaysUntilWeekday:Int(date:TDate, weekday:Int)
- Return bmx_days_until_weekday(date.datePtr, weekday)
- End Function
- Function DaysUntilWeekday:Int(date:TDate, weekday:EWeekday)
- Return bmx_days_until_weekday(date.datePtr, Int(weekday))
- End Function
- Rem
- bbdoc: Calculates the number of day from given date to previous given @weekday.
- about: Valid weekdays include #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday, #EWeekday.Saturday (0-6).
- End Rem
- Function DaysBeforeWeekday:Int(date:TDate, weekday:Int)
- Return bmx_days_before_weekday(date.datePtr, weekday)
- End Function
- Function DaysBeforeWeekday:Int(date:TDate, weekday:EWeekday)
- Return bmx_days_before_weekday(date.datePtr, Int(weekday))
- End Function
- Rem
- bbdoc: Generates a #TDate object representing the date of the following @weekday from the given @date.
- about: Valid weekdays include #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday, #EWeekday.Saturday (0-6).
- End Rem
- Function NextWeekday:TDate(date:TDate, weekday:Int)
- Return New TDate(bmx_next_weekday(date.datePtr, weekday))
- End Function
- Function NextWeekday:TDate(date:TDate, weekday:EWeekday)
- Return New TDate(bmx_next_weekday(date.datePtr, Int(weekday)))
- End Function
- Rem
- bbdoc: Generates a #TDate object representing the date of the previous @weekday from the given @date.
- about: Valid weekdays include #EWeekday.Sunday, #EWeekday.Monday, #EWeekday.Tuesday, #EWeekday.Wednesday, #EWeekday.Thursday,
- #EWeekday.Friday, #EWeekday.Saturday (0-6).
- End Rem
- Function PreviousWeekday:TDate(date:TDate, weekday:Int)
- Return New TDate(bmx_previous_weekday(date.datePtr, weekday))
- End Function
- Function PreviousWeekday:TDate(date:TDate, weekday:EWeekday)
- Return New TDate(bmx_previous_weekday(date.datePtr, Int(weekday)))
- End Function
- Rem
- bbdoc:
- End Rem
- Function EndOfMonthDay:Int(year:Int, month:Int)
- Return bmx_end_of_month_day(year, month)
- End Function
- Function EndOfMonthDay:Int(year:Int, month:EMonth)
- Return bmx_end_of_month_day(year, Int(month))
- End Function
- Rem
- bbdoc: Weekday
- EndRem
- Enum EWeekday:Int
- Sunday
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
- EndEnum
- Rem
- bbdoc: Month
- EndRem
- Enum EMonth:Int
- January = 1
- February
- March
- April
- May
- June
- July
- August
- September
- October
- November
- December
- EndEnum
- Rem
- bbdoc: Nth Day
- EndRem
- Enum ENthDay:Int
- First = 1
- Second
- Third
- Fourth
- Fifth
- EndEnum
|