NSDate と DateTime の相互変換
- 実際にはもうちょっとタイムゾーンとか色々気を使う必要あるけどざっくりまとめ
- https://forums.xamarin.com/discussion/27184/convert-nsdate-to-datetime
NSDate => DateTime
ReferenceDate ってなんなの...(https://developer.apple.com/documentation/foundation/nsdate)
public static class FoundationExtensions
{
public static DateTime ToDateTime(this NSDate date)
{
// ref: https://developer.apple.com/documentation/foundation/nsdate
var referenceDate = new DateTime(2001, 1, 1);
return referenceDate.AddSeconds(date.SecondsSinceReferenceDate);
}
}
public static NSDate ToNSDate(this DateTime dateTime)
{
var universalTime = dateTime.ToUniversalTime();
var date = NSDate.FromTimeIntervalSinceReferenceDate((universalTime - referenceDate).TotalSeconds);
return date;
}
Pinned Articles
About
ウェブ界隈でエンジニアとして労働活動に励んでいる @gomi_ningen 個人のブログです
Tags
LLM
promptfoo
GenAI
JavaScript
PowerShell
kibana
fluentd
elasticsearch
nginx
村川梨衣
五十嵐裕美
イベント
logrotate
IoT
Java
Scala
iputils
C言語
ICMP
WUG
mastodon
Swift
AWS
Clock
Windows
アーキテクチャ
PoEAA
iOS
DeviceFarm
プログラミング言語
OS
Lambda
StepFunctions
Serverless
terraform
ポエム
RHEL
ネットワーク
GraphQL
CloudWatch
Linux
Coreutils
telnet
network
nc
LinuxKernel
fpinscala
ELB
IAM
AppSync